Understanding Incrementing

前端 未结 7 2048
别那么骄傲
别那么骄傲 2020-11-27 22:31

For example this:

var a = 123;
var b = a++;

now a contains 124 and b contains 123

相关标签:
7条回答
  • 2020-11-27 23:20

    ++ can be used as post-increment operator like in your example, or it could be used as a pre-increment operator if used before variable.

    var b = ++a;
    

    Then first the variable a will be incremented, then the incremented value is assigned to b.

    0 讨论(0)
提交回复
热议问题