typeof - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

JavaScript data structure

The following table summarizes the possible return values of typeof. For more information about types and primitives, see also the JavaScript data structure page.

Using new operator

All constructor functions called with new will return non-primitives ("object" or "function"). Most return objects, with the notable exception being Function, which returns a function.

Using new operator

All constructor functions called with new will return non-primitives ("object" or "function"). Most return objects, with the notable exception being Function, which returns a function.

Need for parentheses in syntax

The typeof operator has higher precedence than binary operators like addition (+). Therefore, parentheses are needed to evaluate the type of an addition result.

Interaction with undeclared and uninitialized variables

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

Interaction with undeclared and uninitialized variables

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

Interaction with undeclared and uninitialized variables

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

Interaction with undeclared and uninitialized variables

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

Interaction with undeclared and uninitialized variables

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

Interaction with undeclared and uninitialized variables

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

typeof operator and undefined

typeof works with undeclared identifiers, returning "undefined" instead of throwing an error.

Exceptional behavior of document.all

All current browsers expose a non-standard host object document.all with type undefined.

Exceptional behavior of document.all

All current browsers expose a non-standard host object document.all with type undefined.

Exceptional behavior of document.all

All current browsers expose a non-standard host object document.all with type undefined.

Learn how to contribute

This page was last modified on May 22, 2026 by MDN contributors.

Expressions and operators