01. Operators

Выражения вызова и обращения к свойству имеют более высокий приоритет, чем любой из операторов.

??

The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.

const nullValue = null;
const emptyText = ""; // falsy
const someNumber = 42;

const valA = nullValue ?? "default for A"; // "default for A"
const valB = emptyText ?? "default for B"; // ""
const valC = someNumber ?? 0; // 42

Last updated