Equality & Sameness
2022年5月1日小于 1 分钟
Equality & Sameness
Question
What does the code snippet to the right output by console.log
?
Snippet
console.log(0 == '0')
console.log(0 === '0')
console.log(Object.is(0, '0'))
console.log(0 == 0)
console.log(0 === 0)
console.log(Object.is(0, 0))
console.log(0 == -0)
console.log(0 === -0)
console.log(Object.is(0, -0))
console.log(NaN == NaN)
console.log(NaN === NaN)
console.log(Object.is(NaN, NaN))
console.log(0 == false)
console.log(0 === false)
console.log(Object.is(0, false))