[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/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 7.

undefined undefined , JavaScript .

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 .

Property attributes of undefined

undefined . , .

undefined , . .

undefined . undefined . undefined .

: ( ) undefined (undefined ), . .

js
// DON'T DO THIS

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

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

undefined

undefined , . x , if .

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

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

Equality comparison and sameness .

typeof undefined

typeof .

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

typeof .

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

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

. JavaScript , .

, in . ,

js
if ("x" in window) {
  // x      
}

void undefined

void .

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

// y   
if (y === void 0) {
  // throws Uncaught ReferenceError: y is not defined
}

Specification
ECMAScript 2027 LanguageSpecification
# sec-undefined


Web Proxy Viewer  |  New URL  |  Original Page