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); // trueAdvertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 85
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
428of476