We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一个同事问起为什么这段代码的返回是这样的?
代码块 var i = 0; i = i++ console.log(i) 一些人说是0 ,一些人说是1.其中的原理又是什么呢?
究其原理,++是运算符,=是赋值符。先运算,后赋值。
所以代码相当于
代码块 var i = 0; i = (i++) console.log(i) 代码的+是先返回后自加,问题的关键是自加的语句执行在赋值后还是赋值前?
https://blog.csdn.net/zhangpeng759/article/details/8630198
自加和自减都有一个变量temp来过渡
代码块 var i = 0; // ++ 的运算过程 var temp ; temp = i i = i+1 // return temp i=temp console.log(i) 所以i最后还是0就能解释的通了
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一个同事问起为什么这段代码的返回是这样的?
代码块
var i = 0;
i = i++
console.log(i)
一些人说是0 ,一些人说是1.其中的原理又是什么呢?
究其原理,++是运算符,=是赋值符。先运算,后赋值。
所以代码相当于
代码块
var i = 0;
i = (i++)
console.log(i)
代码的+是先返回后自加,问题的关键是自加的语句执行在赋值后还是赋值前?
https://blog.csdn.net/zhangpeng759/article/details/8630198
自加和自减都有一个变量temp来过渡
所以代码相当于
代码块
var i = 0;
// ++ 的运算过程
var temp ;
temp = i
i = i+1
// return temp
i=temp
console.log(i)
所以i最后还是0就能解释的通了
The text was updated successfully, but these errors were encountered: