Javascript - Null

1 - About

null is a javascript data type that is unfortunately reported as an object by the typeof operator.

null means no object value, whereas undefined means no value.

typeof null returns object, and not null, despite Null being a type of its own.


3 - Management

3.1 - typeof

Confusingly, typeof reports the type of null as “object”, but the ECMA-Script standard describes it as a distinct type.

console.log("null has the type "+typeof(null));

3.2 - Nullish coalescing operator (??)

The Nullish coalescing operator (??) is a short-circuiting operator meant to handle default values.

nullish means that the value is equal to null or undefined.


leftOperand ?? RightOperand


  • If leftOperand is not nullish, it evaluates to leftOperand .
  • Otherwise, it evaluates to RightOperand.


const enable = props.enabled ?? true;

4 - Documentation / Reference

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap