English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript undefined Property

 JavaScript Global Properties/Function

Globalundefined representing that a value has not been assigned to a variable, or that the variable has not been declared at all.

It is a property of JavaScriptOne of the primitive types.

If the variable to be calculated has not been assigned a value, the method or statement will also return undefined.

If the function does not return a value, it returns undefined.

Syntax:

undefined
var str;
if (str === undefined) {
   // str is undefined
} else {
   // str is defined
}
Test and see‹/›

Browser Compatibility

All browsers fully support the undefined property:

Property
undefinedIsIsIsIsIs

Technical Details

Writable:None
Enumerable:None
Configurable:None
JavaScript Version:ECMAScript 1

ECMAScript

More Examples

Check if the variable str is defined or undefined:39;if (typeof str === 'undefined&#
   // str is undefined
} else {
   // str is defined
}
Test and see‹/›

If no value is returned, the function returns undefined:

function demo() {
   return; // return nothing....
}
;document.getElementById('result').innerHTML = demo();
Test and see‹/›

 JavaScript Global Properties/Function