isNaN() 在传递 BigInt 时抛出错误

isNaN() throwing an error when passing a BigInt

为什么函数 isNaN() 在将 BigInt 作为参数传递时抛出错误?

错误:

Uncaught TypeError: Cannot convert a BigInt value to a number
    at isNaN (<anonymous>)
    at <anonymous>:1:1

要复制的代码:

let i = BigInt('2');
isNaN(i);

它是一个对象,如果你需要将它转换成一个数字你可以简单地使用Number,例如:

let i = BigInt('2');
isNaN(Number(i));

console.log(isNaN(Number(i)));