+ 3
Why is it true?
4 Réponses
+ 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
+ 3
Shivam agrawal do not copy answers from others, if you have nothing to contribute better do not say anything
+ 2
luis calderón Thanks so much! ☺️☺️☺️
0
It's return true because a is a not null object so if you try a==0 you will see false ...