Nullish coalescing operator (??)

The Nullish coalescing operator(??) is a logical operator that returns the right side operand when its left side operand is null or undefined, otherwise it returns left side operand.

For Example:-

const foo =  null ?? "it is foo";  // output   it is foo

const baz = 0 ??  44  // output 44

The Logical operator (| |) is differs from Nullish coalescing operator(??)

Logical operator (| |) is returns the right side operands if left side operands is falsy (" " /' '/``, 0, -0, 0n, false, null, undefined,) ,not only null or undefined,otherwise returns left side operands.

For Example:-

const checkNumber=  2 ||  "it is foo";  // output   2

const checkString= "" || "100" // output 100

const message = 0 ||  hello  // output hello