Some confusing stuff about JavaScript

How do these make any sense?

ewqefqew

Hello @Anindya.

I don’t know where you got that and what you are up to . Be careful about how you use isNaN like that. There is isNaN and Number.isNaN. This is what the folks at MDN say about isNaN. The very first paragraph.

The isNaN() function determines whether a value is NaN or not. Note, coercion inside the isNaN function has interesting rules; you may alternatively want to use Number.isNaN() , as defined in ECMAScript 2015.

Check more below:

1 Like

type coercion

an empty object can’t be coerced to a number, so it gives NaN

an empty array is coerced to 0, which is a number

true coerced to a number is 1, so sum three of them to get 3

last one is equality, with type coercion included

2 Likes

That explains it! if I say true === 1 it outputs false. I’ll go ahead and do some studying on type coercion :3