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 foo = null ?? 'default string'; console.log(foo); // expected output: "default string" const baz = 0 ?? 42; console.log(baz); // expected output: 0 const bar = undefined ?? 'default string'; console.log(bar); // expected output: default string
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.