I use Chrome browser 60.x, and test the code isNaN([3])
.
The result is false
, but I cannot understand it.
[3]
is an Array, and it is not empty.
I think [3]
is array object, and it is not an number.
Otherwise the result of isNaN(["ABC"])
is true
.
And another result of isNaN([1,2,3])
is true
.
So I guess javascript engine is force changing array to number which the array has a single element.
Please let me know what is happened isNaN
function for array parameter.
ref1: Why is isNaN(null) == false in JS?
ref2: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN
[EDIT] Thank you everyone for answering.
I understand javascript parsed the value implicitly before comparison.
And I found a useful link while reading Nina Scholz's answer.
The comparison table : http://dorey.github.io/JavaScript-Equality-Table/