JavaScript NaN with BibInt return strange types

97 Views Asked by At

I can understand why NaN is a 'number' but can someone explain to me why

console.log(typeof 1n+NaN);
console.log(typeof NaN+1n);

There is no such types in documentation.

1

There are 1 best solutions below

0
Eugene On

It happens because return type of typeof is string and you don't use brackets.

It equals to:

typeof(Nan); //'number'
'number' + 1n; //'number1'