Nullish coalescing operator '??'
What is the Nullish coalescing operator '??' in JavaScript? The Nullish coalescing operator '??' is a new addition to JavaScript introduced in ECMAScript 2020. It is used to provide a default value when the value on the left-hand side of the operator is null or undefined. The '??' operator can be seen as a shorthand way of writing a conditional statement to check for null or undefined values and provide a default value in such cases. Syntax The syntax of the Nullish coalescing operator is as follows: valueToCheck ?? defaultValue valueToCheck ?? defaultValue result = a ?? b ; The result of a ?? b is: if a is defined, then a, if a isn’t defined, then b. We can rewrite result = a ?? b using the operators that we already know, like this: result = ( a !== null && a !== undefined ) ? a : b ; It means that, the express...