January 2020
Intermediate to advanced
548 pages
13h 36m
English
The null primitive type is used to express the intentional absence of a value. It is a type with only one value: the only null value is null.
The semantics of null are crucially different from undefined. The undefined value is used to indicate something that is not declared or defined, while null is an explicitly declared absent value. We usually use the null value to indicate that a value is either explicitly not yet set or, for whatever reason, unavailable.
For example, let's consider an API where we specify various properties related to a restaurant review:
setRestaurantFeatures({ hasWifi: false, hasDisabledAccess: true, hasParking: null});
The null value, in this context, means that we do not know the value of hasParking yet. When ...
Read now
Unlock full access