We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

undefined Property

Returns the value of undefined.


The undefined property is a member of the Global object, and becomes available when the scripting engine is initialized. When a variable has been declared but not initialized, its value is undefined.

If a variable has not been declared, you cannot compare it to undefined, but you can compare the type of the variable to the string "undefined".

The undefined property is useful when explicitly testing or setting a variable to undefined.


To compile a program that uses an undeclared variable from the command line, you must turn off the fast option by using /fast-. Undeclared variables cannot be used when a program is running in fast mode. It is not safe to turn off the fast option in ASP.NET because of threading issues.

var declared;
if (declared == undefined)
    print ("declared has not been given a value");
    print ("declared has been given a value");

print ("typeof declared is " + typeof(declared));

// An undeclared variable cannot be compared to undefined,
// so the next line would generate an error.
// if (notDeclared == undefined) ;

print ("typeof notDeclared is " + typeof(notDeclared));

The output of this code is as follows.

declared has not been given a value
typeof declared is undefined
typeof notDeclared is undefined