const x = NaN // Please fill in the value of "x?if (x !== x) { console.log('hello fatfish')}console.log(NaN === NaN) // falseconsole.log(x !== x) // trueconsole.log(Number.isNaN(x)) // true
1.
2. (!isNaN(x) && x !== x) 可以返回true吗?
好的,当我们过滤掉“NaN”时,还有什么值可以让一个值不等于自己呢?
constx=?// Please fill in the value of "x?if(!isNaN(x) && x !== x) { console.log('hello fatfish')}
1.
也许你知道“object.Defineproperty”,它可以帮助我们解决这个问题。
window.x=0// Any value is OKObject.defineProperty(window, 'x', { get () { return Math.random() }})console.log(x) // 0.12259077808826002console.log(x === x) // falseconsole.log(x !== x) // true
constx=document.all// Please fill in the value of "x?if(typeof x === 'undefined' && x.length > 0) { console.log('hello fatfish')}console.log(x)console.log(typeofx)console.log(x===undefined)