What's the output ? var x= 2+false; alert(x); | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's the output ? var x= 2+false; alert(x);

8th Jul 2019, 5:12 PM
Rohit Kumar Srivastava
4 Answers
+ 11
The output will be : 2
8th Jul 2019, 5:13 PM
VEDANG
VEDANG - avatar
+ 11
Airree The question is changed/edited. Earlier it was: var x = x + false so the output was: NaN
8th Jul 2019, 5:18 PM
VEDANG
VEDANG - avatar
+ 3
VEDANG No, it won't be. False is converted to a number (0), then added to 2, 2 + 0 = 2
8th Jul 2019, 5:16 PM
Airree
Airree - avatar
0
Yeah right output will be 2.
8th Jul 2019, 5:17 PM
Rohit Kumar Srivastava