In JavaScript, the double query mark operator (??) is a logical operator that evaluates to the worth of its right-hand operand if its left-hand operand is null or undefined, and in any other case evaluates to the worth of its left-hand operand.
The double query mark operator is usually used to supply a default worth for a variable or operate parameter. For instance, the next code snippet makes use of the double query mark operator to supply a default worth of “Unknown” for the title variable:
const title = consumer.title ?? "Unknown";
The double query mark operator may also be used to chain a number of default values. For instance, the next code snippet makes use of the double query mark operator to supply a default worth of “Unknown” for the title variable, and a default worth of “instance@e mail.com” for the e-mail variable: