Skip to main content

Command Palette

Search for a command to run...

JavaScript - The typeof operator

Updated
•1 min read•View as Markdown
JavaScript - The typeof operator
D

I'm a Software Engineer with 9+ years of experience. I've extensive knowledge of different technologies and programming languages. I've skills in Web Development, Databases, and Agile Methodologies. I'm constantly looking to explore new technologies and new opportunities to learn.

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 
"undefined"

typeof 0 
"number"

typeof 10n
"bigint"

typeof true
"boolean"

typeof "foo"
"string"

typeof Symbol("id") 
"symbol"

typeof Math 
"object"

typeof null 
"object"

typeof alert 
"function"

More from this blog

Untitled Publication

8 posts