isNaN是判断一个数是否为NaN类型,这还包括其他数据类型在转换为Number类型时变成为NaN的情况
console.log(isNaN('a'));//true console.log(isNaN(1));//false console.log(isNaN('undefinded'));//true console.log(isNaN(NaN));//true
Number.isNaN首先必须满足为Number类型,因为其他类型的数据不会强行转为Number类型,因此只有NaN的结果为true
console.log(Number.isNaN(1));//false console.log(Number.isNaN("a"));//false console.log(Number.isNaN(NaN));//true console.log(Number.isNaN(null));//false
标签:isNaN,console,log,区别,NaN,Number,true From: https://www.cnblogs.com/lwqboke/p/16637427.html