Search⌘ K
AI Features

The typeof Operator

Explore the use of the JavaScript typeof operator to identify data types such as functions, arrays, and objects. Understand how ES6 improved type detection, and learn practical ways to differentiate between arrays, objects, and null values.

The typeof operator accepts one operand and returns a string. This string describes the type of object.

Node.js
typeof '' // "string"
typeof 0 // "number"
typeof true // "boolean"
typeof {} // "object"
typeof [] // "object"
typeof null // "object"
typeof undefined // "undefined"
typeof Symbol() // "symbol"
...