Check if something is null or undefined.
null
undefined
Time complexity: O(1)
Space complexity: O(1)
Value to check
true if value is nullish, false if otherwise
true
value
false
const value = Math.random() > 0.5 ? 'hello' : null;nullish(value); Copy
const value = Math.random() > 0.5 ? 'hello' : null;nullish(value);
Check if something is
null
orundefined
.Time complexity: O(1)
Space complexity: O(1)