JavaScript undefined Property
Example
Test if a variable is undefined:
var x;
if (typeof x === "undefined") {
txt = "x is undefined";
} else {
txt = "x is defined";
}
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The undefined property indicates that a variable has not been assigned a value, or not declared at all.
Browser Support
| Property | |||||
|---|---|---|---|---|---|
| undefined | Yes | Yes | Yes | Yes | Yes |
Technical Details
| JavaScript Version: | ECMAScript 1 |
|---|
More Examples
Example
Test if a not declared variable is undefined:
if (typeof y === "undefined") {
txt = "y is undefined";
} else {
txt = "y is defined";
}
Try it Yourself »
❮ JavaScript Global Functions

