Web_Designer提出了一个问题:javascript i++ vs ++i,或许与您遇到的问题类似。
回答者Guffa给出了该问题的处理方式:
The difference between i++
and ++i
is the value of the expression.
The value i++
is the value of i
before the increment. The value of ++i
is the value of i
after the increment.
Example:
var i = 42; alert(i++); // shows 42 alert(i); // shows 43 i = 42; alert(++i); // shows 43 alert(i); // shows 43
The i--
and --i
operators works the same way.
希望本文对你有帮助,欢迎支持JavaScript中文网