January 2020
Intermediate to advanced
548 pages
13h 36m
English
The undefined primitive type expresses that something hasn't been defined yet or remains undefined. Like null, it is a type with only one value (undefined). Unlike null, an undefined value should not be explicitly set, but may be returned by the language when something does not have a value:
const coffee = { type: 'Flat White', shots: 2};coffee.name; // => undefinedcoffee.type; // => "Flat White"
Undefined is best thought of as the absence of something. If you ever find yourself wishing to explicitly set something to undefined, you should probably reach for null instead.
It's important to distinguish between the concepts of undefined and not even declared. In JavaScript, if you try to evaluate an identifier that does not exist ...
Read now
Unlock full access