English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
undefined
var str; if (str === undefined) { // str is undefined } else { // str is defined }Test and see‹/›
All browsers fully support the undefined property:
Property | |||||
undefined | Is | Is | Is | Is | Is |
Writable: | None |
---|---|
Enumerable: | None |
Configurable: | None |
JavaScript Version: | ECMAScript 1 |
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‹/›