Why is it true? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
31st Jan 2021, 6:57 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
4 Answers
+ 7
The explanation is in the method valueOf() . When a is called returns valueOf taht is this.num += 1; a == 1 //first a.num increases in 1 then check a == 1 and return true //now a.num has 1 a == 2 //a.num increase in 1 one more time, a.num has 2, and return true Please read https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf
31st Jan 2021, 7:15 PM
CoffeeByte
CoffeeByte - avatar
+ 3
Shivam agrawal do not copy answers from others, if you have nothing to contribute better do not say anything
31st Jan 2021, 7:46 PM
CoffeeByte
CoffeeByte - avatar
+ 2
luis calderón Thanks so much! ☺️☺️☺️
31st Jan 2021, 8:10 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
0
It's return true because a is a not null object so if you try a==0 you will see false ...
31st Jan 2021, 8:24 PM
Nathanaël Zuchuon
Nathanaël Zuchuon - avatar