| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Operators/typeof | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..
typeof , .
console.log(typeof 42);
// Expected output: "number"
console.log(typeof "blubber");
// Expected output: "string"
console.log(typeof true);
// Expected output: "boolean"
console.log(typeof undeclaredVariable);
// Expected output: "undefined"
typeof:
typeof operand
typeof. JavaScript.
| Type | Result |
|---|---|
| Undefined | "undefined" |
| Null | "object" ( ) |
| Boolean | "boolean" |
| Number | "number" |
| String | "string" |
| Symbol ( ECMAScript 2015) | "symbol" |
| Host object ( JS ) | |
| Function object ( [[Call]] ECMA-262) | "function" |
"object" |
//
typeof 37 === "number";
typeof 3.14 === "number";
typeof 42 === "number";
typeof Math.LN2 === "number";
typeof Infinity === "number";
typeof NaN === "number"; // , "Not-A-Number" ( )
typeof Number(1) === "number"; // !
//
typeof "" === "string";
typeof "bla" === "string";
typeof "1" === "string"; // ,
typeof typeof 1 === "string"; // typeof
typeof String("abc") === "string"; // !
// Booleans
typeof true === "boolean";
typeof false === "boolean";
typeof Boolean(true) === "boolean"; // !
//
typeof Symbol() === "symbol";
typeof Symbol("foo") === "symbol";
typeof Symbol.iterator === "symbol";
// Undefined
typeof undefined === "undefined";
typeof declaredButUndefinedVariable === "undefined";
typeof undeclaredVariable === "undefined";
//
typeof { a: 1 } === "object";
// Array.isArray Object.prototype.toString.call
//
typeof [1, 2, 4] === "object";
typeof new Date() === "object";
// . !
typeof new Boolean(true) === "object";
typeof new Number(1) === "object";
typeof new String("abc") === "object";
//
typeof function () {} === "function";
typeof class C {} === "function";
typeof Math.sin === "function";
null// JavaScript
typeof null === "object";
JavaScript . 0. null (0x00 ). , null , typeof . ()
ECMAScript ( ), . , typeof null === 'null'.
new// -, 'new', 'object'
var str = new String("String");
var num = new Number(100);
typeof str; // 'object'
typeof num; // 'object'
// Function
var func = new Function();
typeof func; // 'function'
.
typeof /s/ === "function"; // Chrome 1-12 ECMAScript 5.1
typeof /s/ === "object"; // Firefox 5+ ECMAScript 5.1
ECMAScript 2015, , typeof , . let and const . , let const, typeof , , ReferenceError. , typeof 'undefined'. " ", . .
typeof undeclaredVariable === "undefined";
typeof newLetVariable;
let newLetVariable; // ReferenceError
typeof newConstVariable;
const newConstVariable = "hello"; // ReferenceError
host- document.all, Undefined.
typeof document.all === "undefined";
, . , document.all undefined .
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-typeof-operator |
IE 6, 7 8 host- , . :
typeof alert === "object";
This page was last modified on 24 . 2025 . by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |