U-X > undefined

 

undefined

지원 버전

Flash Player 5

구문

undefined

매개 변수

없음

반환값

없음

설명

일반적으로 아직 변수에 값이 지정되지 않았음을 나타내는 특정 값입니다. 정의되지 않은 값을 참조하면 undefined라는 특정 값이 반환됩니다. ActionScript 코드 typeof(undefined)는 문자열 "undefined"를 반환합니다. undefined 유형의 유일한 값은 undefined입니다.

undefined가 문자열로 변환되면 빈 문자열로 변환됩니다.

undefined 값은 null과 비슷합니다. 실제로 null과 undefined를 동격 연산자와 비교하면 동일한 것으로 비교됩니다.

예제

이 예제에서 변수 x는 선언되지 않았으므로 undefined 값을 갖습니다. 첫 번째 코드 섹션에서 동격 연산자(==)는 x 값을 undefined 값과 비교하고, 해당 결과는 출력 창에 보내집니다. 두 번째 코드 섹션에서 동격 연산자는 null 값과 undefined 값을 비교합니다.

// x has not been declared
trace ("The value of x is " + x);
if (x == undefined) {
  trace ("x is undefined");
} else {
  trace ("x is not undefined");
}

trace ("typeof (x) is " + typeof (x));
if (null == undefined) {
  trace ("null and undefined are equal");
} else {
  trace ("null and undefined are not equal");
}

다음 결과가 출력 창에 표시됩니다.

The value of x is x is undefined
typeof (x) is undefined
null and undefined are equal

참고: ECMA-262 사양에서 undefined는 빈 문자열이 아닌 문자열 "undefined"로 변환됩니다. 이것이 ActionScript와 ECMA-262 사양의 차이입니다.