As we mentioned in this section, any value has a type assigned. Use the typeof operator to get a string representation of a type:

typeof 1 //'number'
typeof '1' //'string'
typeof {name: 'Flavio'} //'object'
typeof [1, 2, 3] //'object'
typeof true //'boolean'
typeof undefined //'undefined'
typeof (() => {}) //'function'
typeof Symbol() //'symbol'

JavaScript has no “function” type, and it seems funny that typeof returns 'function' when we pass it a function.

It’s one quirk of it, to make our job easier.

Go to the next lesson