Recently I was asked a few strange interview questions. They are different from the regular questions: these interview questions seem very easy, but they test your thorough understanding of JavaScript. How many can you answer correctly?
1. Can “x !== x” return true?
What should be the value of “x” to output “hello fatfish”?
It’s amazing. Is there any value that is not equal to itself? However, there is a value NaN
in JavaScript, which is not equal to any value or even itself.
2. Can (!isNaN(x) && x !== x) return true?
Okay, when we filter out “NaN”, what other value can make a value not equal to itself?
Maybe you know “object. Defineproperty”, which can help us solve this problem.