JS Coding Questions Logo
JS Coding Questions
#428💼 Interview💻 Code

What is nullish coalescing operator (??)?

Advertisement

728x90

It 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. This can be contrasted with the logical OR (||) operator, which returns the right-hand side operand if the left operand is any falsy value, not only null or undefined.

js
1console.log(null ?? true); // true
2
3console.log(false ?? true); // false
4
5console.log(undefined ?? true); // true

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 85

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
428of476