JavaScript - The typeof operator

JavaScript - The typeof operator

Table of contents

No heading

No headings in the article.

The typeof operator returns the type of the argument. It’s useful when we want to process values of different types differently or just want to do a quick check.

A call to typeof x returns a string with the type name:

typeof undefined 

typeof 0 

typeof 10n

typeof true

typeof "foo"

typeof Symbol("id") 

typeof Math 

typeof null 

typeof alert