In JavaScript, the double question mark operator (??) is a logical operator that evaluates to the value of its right-hand operand if its left-hand operand is null or undefined, and otherwise evaluates to the value of its left-hand operand.
The double question mark operator is often used to provide a default value for a variable or function parameter. For example, the following code snippet uses the double question mark operator to provide a default value of “Unknown” for the name variable:
const name = user.name ?? "Unknown";
The double question mark operator can also be used to chain multiple default values. For example, the following code snippet uses the double question mark operator to provide a default value of “Unknown” for the name variable, and a default value of “example@email.com” for the email variable: