[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/undefined [Back]  [Original]

undefined - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

undefined

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..

undefined undefined. JavaScript.

undefined

In this article

function test(t) {
  if (t === undefined) {
    return "Undefined value!";
  }
  return t;
}

let x;

console.log(test(x));
// Expected output: "Undefined value!"

undefined

undefined , , . undefined undefined.

(JavaScript 1.8.5 / Firefox 4+), undefined , ECMAScript 5. , .

, , undefined. undefined , , , . undefined, - .

: , undefined ( ) , ( undefined ), , .

js
//   

(() => {
  const undefined = "foo";
  console.log(undefined, typeof undefined); //  foo
})();

((undefined) => {
  console.log(undefined, typeof undefined); //  foo
})("foo");

: undefined

undefined , . x if true.

js
var x;
if (x === undefined) {
  //    
} else {
  //     
}

: () , x == undefined , x null, . null undefined. .

: typeof undefined

typeof:

js
var x;
if (typeof x === "undefined") {
  //    
}

typeof , , .

js
//  x    
if (typeof x === "undefined") {
  //   true  
  //    
}

if (x === undefined) {
  //  ReferenceError
}

, . JavaScript , , , , . , , (, in).

: void undefined

void.

js
var x;
if (x === void 0) {
  //    
}

//  y    
if (y === void 0) {
  //  ReferenceError (    `typeof`)
}

Specification
ECMAScript 2027 LanguageSpecification
# sec-undefined


Web Proxy Viewer  |  New URL  |  Original Page