Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

?? in javascript

"??" is called Nullish coalescing operator.
return the right hand side of operator if left hand side is null or undefined.
For example.
const foo = null ?? 'default string';
console.log(foo);
// expected output: "default string" because left hand side is null

const baz = 0 ?? 42;
console.log(baz);
// expected output: 0 . because 0 is not null or undefined.
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
4+1 =