What is a "null coalescing" operator in JavaScript?

JavascriptWeb DevelopmentFront End Technology

The ?? operator is the “null coalescing” operator in C#, but JavaScript has an operator like this, i.e. ||.

The operator || is the logical OR operator. If any of the two operands are non-zero, then the condition becomes true. 


Here’s how you can use the operator || with var in JavaScript −

         var a = true;
         var b = false;

         document.write("(a || b) => ");
         result = (a || b);
Published on 19-Jan-2018 05:29:05