标签:过程 ring htm github let strong eval mit str
1. !优先级高于== 所以先执行![].
根据标准:
The production UnaryExpression : !
UnaryExpression is evaluated as follows:
Let expr be the result of evaluating UnaryExpression.
If oldValue is true, return false.
Return true.
![] 相当于 false;此时 []==![] 等价于 []==false
2. []==false;
根据标准:
If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
此时, []==false 等价于 []==0;
3.[]==0;
根据标准:
If Type(x) is either String or Number and Type(y) is Object,
return the result of the comparison x == ToPrimitive(y).
ToPrimitive : http://es5.github.io/index.html#x9.1
如果 最终 []==0 等价于 ""==0;
4.""==0;
根据标准:
根据 ToNumber() http://es5.github.io/index.html#x9.3
"" 被转成0
此时 ""==0 等价于 0==0;
返回true
标签:过程 ring htm github let strong eval mit str
原文地址:http://www.cnblogs.com/Mr-Joe/p/4237136.html