VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-undefined-property/

⇱ JavaScript undefined Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript undefined Property

Last Updated : 8 Feb, 2023

The undefined property is used to check if a value is assigned to a variable or not

Syntax:

var x;
if (typeof x === "undefined") {
 txt = "x is undefined";
} else {
 txt = "x is defined";
}

Return Value: It returns 'defined' if the variable is assigned any value and 'undefined' if the variable is not assigned any value. More example code for the above property are as follows: 

Below are examples of the undefined Property.

Example 1: 

Output:

'a' is defined

Example 2: 

Output: 

👁 Image

Supported Browsers:

  • Google Chrome
  • Firefox
  • Internet Explorer
  • Opera
  • Safari
Comment