This relates to the Not-a-number function.
The following is the wrong way to use the isNaN() wherein the Number prototype is not specified:
☑️ The correct way to use isNaN()
When working with isNaN() we must always use the Number prototype to call it:
ConclusionThis gem of an answer below, clearly states this, and this blog article can act as a reference point for the future when working with isNaN():Due to both equality operators,
===, evaluating to false when checking if NaN is NaN, the function
Number.isNaN()has become necessary.In comparison to the global isNaN() function,
Number.isNaN()doesn’t suffer the problem of forcefully converting the parameter to a number.This means it is now safe to pass values that would normally convert to NaN, but aren’t actually the same value as NaN.This also means that only values of the type number, that are also NaN, return true.