js +1问题
2020-07-29 本文已影响0人
我想专心学习
js中的x=x+1、x++最后得到的是字符串拼接结果
var x=1
typeof(x+1) //’string’
typeof(x-1) //’number’
typeof(+x) //’number’
typeof(-x) //’number’
typeof(++x) //’number’
可以用++x替换
js中的x=x+1、x++最后得到的是字符串拼接结果
var x=1
typeof(x+1) //’string’
typeof(x-1) //’number’
typeof(+x) //’number’
typeof(-x) //’number’
typeof(++x) //’number’
可以用++x替换