[]==[]输出ture或者false? []==![]输出ture或者false?
时间:2011-12-27
来源:互联网
[]==[]输出ture或者false? []==![]输出ture或者false?
js中
![]是flase的意思?
求大神解释
js中
![]是flase的意思?
求大神解释
作者: qq6160625 发布时间: 2011-12-27
因为:false、0、null、 NaN、'' 为 false其他均为true
推论:typeof [] == 'object' && [] !== null
所以:Boolean([]) = true
所以:!Boolean([]) = false
[] == ![]
[] == false
Number([]) == 0
0 == false => true
ECMA-262
The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:
1.If Type(x) is the same as Type(y), then
a.If Type(x) is Undefined, return true.
b.If Type(x) is Null, return true.
c.If Type(x) is Number, then
i.If x is NaN, return false.
ii.If y is NaN, return false.
iii.If x is the same Number value as y, return true.
iv.If x is +0 and y is −0, return true.
v.If x is −0 and y is +0, return true.
vi.Return false.
d.If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions). Otherwise, return false.
e.If Type(x) is Boolean, return true if x and y are both true or both false. Otherwise, return false.
f.Return true if x and y refer to the same object. Otherwise, return false.
2.If x is null and y is undefined, return true.
3.If x is undefined and y is null, return true.
4.If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).
5.If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.
6.If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
7.If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
8.If Type(x) is either String or Number and Type(y) is Object, return the result of the comparison x == ToPrimitive(y).
推论:typeof [] == 'object' && [] !== null
所以:Boolean([]) = true
所以:!Boolean([]) = false
[] == ![]
[] == false
Number([]) == 0
0 == false => true
ECMA-262
The comparison x == y, where x and y are values, produces true or false. Such a comparison is performed as follows:
1.If Type(x) is the same as Type(y), then
a.If Type(x) is Undefined, return true.
b.If Type(x) is Null, return true.
c.If Type(x) is Number, then
i.If x is NaN, return false.
ii.If y is NaN, return false.
iii.If x is the same Number value as y, return true.
iv.If x is +0 and y is −0, return true.
v.If x is −0 and y is +0, return true.
vi.Return false.
d.If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions). Otherwise, return false.
e.If Type(x) is Boolean, return true if x and y are both true or both false. Otherwise, return false.
f.Return true if x and y refer to the same object. Otherwise, return false.
2.If x is null and y is undefined, return true.
3.If x is undefined and y is null, return true.
4.If Type(x) is Number and Type(y) is String, return the result of the comparison x == ToNumber(y).
5.If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x) == y.
6.If Type(x) is Boolean, return the result of the comparison ToNumber(x) == y.
7.If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).
8.If Type(x) is either String or Number and Type(y) is Object, return the result of the comparison x == ToPrimitive(y).
作者: zswang 发布时间: 2011-12-27
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28