Few experiments
I am going to write some Maths expressions in JS and wondered:
typeof(Infinity) // "number", in Maths it is NOT a number
typeof(NaN) // "number", how NaN (Not A Number) can actually be a number?
And just a few more experiments:
Infinity === Infinity // TRUE
Infinity * 2 === Infinity * 5 // TRUE, so 2===5 if Infinity !== 0?
However, this makes sense to me:
NaN * 2 === NaN * 5 // FALSE
Questions
- Why JS is designed so? Was there a particular reason for that?
- Are there potentials threats when writing Maths expressions in JS?