Answer the question
In order to leave comments, you need to log in
Why doesn't the method of the Number object run in this case?
An object 's methodNumber
isNaN
must determine whether the value is NaN
or not.
let a = 10;
console.log(a.isNaN()); //a.isNaN is not a function
Answer the question
In order to leave comments, you need to log in
The isNaN method, which is listed in the list of Number methods, is a method of the Number itself, and not an instance, so you need to call it:
Number.isNaN(a)
This is just a global function for checking for NaN, in ec6 it is also a static method of the Number.isNaN constructor.
It does not appear in the number prototype
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question