undefined value
The undefined value stands
for "undefined". JavaScript has a
similar null
value that denotes the absence of
a value. The difference is that
null denotes an intentional
absence (explicitly written in a
code), while undefined is
simply the absence of any information
about the element type and its value.
Syntax
undefined;
Example
Let's find out the variable value that was declared without a value:
let test;
console.log(test);
The code execution result:
undefined
Example
Let's find out the value of a non-existent array element:
let arr = ['a', 'b', 'c'];
console.log(arr[5]);
The code execution result:
undefined
Example
Let's find out the value of a non-existent object element:
let obj = {'a': 1, 'b': 2, 'c': 3};
console.log(obj['e']);
The code execution result:
undefined