1. !優先級高於== 因此先執行![].html
根據標準:git
The production UnaryExpression : !
UnaryExpression is evaluated as follows:github
Let expr be the result of evaluating UnaryExpression.lua
If oldValue is true, return false.code
Return true.htm
![] 至關於 false;此時 []==![] 等價於 []==falseget
2. []==false;it
根據標準:io
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