# 面试官：x可以不等于它自身吗？

### x !== x 可以为 true ?

``````const x = ? // ？？
if (x !== x) {
console.log('大迁世界')
}
``````

``````const x = NaN
if (x !== x) {
console.log('大迁世界')
}
console.log(NaN === NaN) // false
console.log(x !== x) // true
console.log(Number.isNaN(x)) // true
``````

### (!isNaN(x) && x !== x) 可以为 true?

``````const x = ?
if(!isNaN(x) && x !== x) {
console.log('hello fatfish')
}
view rawq2-1.js hosted with
``````

``````window.x = 0
Object.defineProperty(window, 'x', {
get () {
return Math.random()
}
})
console.log(x) // 0.12259077808826002
console.log(x === x) // false
console.log(x !== x) // true
``````

### 3.如何让 `x === x + 1`

``````const x =  Number.MAX_SAFE_INTEGER + 1
if (x === x + 1) {
console.log('大迁世界')
}

``````

### 4. `x > x` 可以为 `true`?

``````const x = ?
if (x > x) {
console.log('hello fatfish')
}
``````

``````const x = {
value: 1,
[ Symbol.toPrimitive ] () {
console.log('x', this.value)
return --this.value
}
}

if (x > x) {
console.log('大迁世界')
}
``````

### 5. typeof x === ‘undefined’ && x.length > 0

``````const x = ?
if(typeof x === 'undefined' && x.length > 0) {
console.log('大迁世界')
}
``````

``````const x = document.all
if(typeof x === 'undefined' && x.length > 0) {
console.log('大迁世界')
}

console.log(x)
console.log(typeof x)
console.log(x === undefined)
``````