Advertisement
728x90
If you prepend the additive(+) operator on falsy values(null, undefined, NaN, false, ""), the falsy value converts to a number value zero. Let's display them on browser console as below,
javascript
1console.log(+null); // 0
2
3console.log(+undefined); // NaN
4
5console.log(+false); // 0
6
7console.log(+NaN); // NaN
8
9console.log(+""); // 0Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 18
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
361of476