JavaScript typeof returns and falsy values

JavaScript typeof returns and falsy values

typeof returns

typeof "Hello"        // string
typeof 100            // number
typeof true           // boolean
typeof undefined      // undefined
typeof function() {}  // function
typeof Symbol()       // symbol
typeof {name: "andy"} // object
typeof [1, 2, 3]      // object
typeof /^\d+/         // object
typeof NaN            // number
typeof null           // object

falsy values

  • false
  • 0
  • -0
  • ""
  • NaN
  • null
  • undefined

js