undefined global variableS2C Home « Globals « undefined

The JavaScript global variable undefined can be used to determine if assignment has taken place and is returned from methods and functions when no value is available.

  • Variables that are not initialized have a type of undefined.
  • Uninitialized variables evaluated in methods and statements return undefined.
  • Functions with no return value return undefined.


The code below just creates a variable without a value.

// Create an uninitialised variable and display it.
var undefinedVariable;

// Create three undefined variables.
var dVariable, eVariable, fVariable;
alert(dVariable + ' ' + eVariable + ' ' + fVariable);

Press the button below to action the above code:

Related Tutorials

JavaScript Basic Tutorials - Lesson 6 - Variables

go to home page Homepage go to top of page Top