Why +[] or +"" equal to 0 in javascript
This question already has an answer here:
Because empty string ("")
is false
in javascript (As Javascript is a dialect of ECMAScript, and ECMAScript language specification clearly defines this behavior) and +
unary operator converts false
to 0
.
Reference : http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
链接地址: http://www.djcxy.com/p/48056.html上一篇: JavaScript的内建字符串是什么?