提问人:Nice18 提问时间:11/22/2021 最后编辑:Nice18 更新时间:6/16/2022 访问量:139
JavaScript:为什么输出是假的?[复制]
JavaScript: Why is the output false? [duplicate]
问:
console.log(`${window === this} (window === this)`)
console.log(`${window === self} (window === self)`)
console.log(`${this === self} (this === self)`)
console.log(`${window === this === self} (window === this === self)`)
为什么在 JavaScript 中是 falsewindow === self === this
答:
1赞
Spectric
11/22/2021
#1
因为不等于 .true
this
此表达式:
window === self === this
相当于:
true === this
这是错误的,因为不是布尔值。this
0赞
Olian04
11/22/2021
#2
因为你不能在 javascript 中以这种方式链接相等运算符。 实际上与:首先计算括号的地方相同。换言之,等于 的计算结果为 。window === this === self
(window === this) === self
window === this === self
true === self
false
评论
a === b === c
(a === b) === c
true === c
c