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

What is the output of prepend additive operator on falsy values

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(+""); // 0

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 18

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
361of476