3

Why are these different?

typeof 0/0 === 'number' // returns false

while

value = typeof 0/0;
typeof value === 'number';  // returns true 

Thanks!!

René Wolferink
  • 3,558
  • 2
  • 29
  • 43
Itai Noam
  • 3,815
  • 3
  • 18
  • 14
  • 3
    First seems to eval as `(typeof 0)/0` so it's `NaN` and not equal to `'number'`. Second is `typeof NaN` and you get `'number'`. – fuyushimoya Nov 09 '15 at 10:25
  • 1
    http://stackoverflow.com/questions/2801601/why-does-typeof-nan-return-number – Andreas Nov 09 '15 at 10:26
  • 1
    Thanks. The reason one is false while the other is true is because of the order of operation (like fuyushimoya wrote). – Itai Noam Nov 09 '15 at 11:52

0 Answers0