1

Consider this code:

typeof null == 'object'//returns  true

And Consider this code:

typeof null == '' //returns  false

Why?

2 Answers2

9

The history of “typeof null”

A long-standing bug, since the beginning of JS.

Sujith PS
  • 4,776
  • 3
  • 34
  • 61
Scimonster
  • 32,893
  • 9
  • 77
  • 89
-2

typeof(null) returns "object"

and

 typeof('') returns "string"!
Ali RAN
  • 563
  • 5
  • 17