Understanding Incrementing

前端 未结 7 2178
别那么骄傲
别那么骄傲 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 22:59

    When you put the ++ after the variable, it gets incremented after the assignment. You can also put the ++ before the variable and it gets incremented before the assignment.

    Javascript actually behaves exactly the same way as PHP for prefix and postfix incrementing.

提交回复
热议问题