+ 3

How can a=1 and a=2 at the same time?

https://www.sololearn.com/post/249114/?ref=app I got this question in sololearn challenges but not getting how the object a can be equal 1 and 2 at the same time

22nd Feb 2020, 6:49 AM
Hafsa Mohamed
Hafsa Mohamed - avatar
1 Antwort
+ 4
Hafsa Hussein It's because of coercing concept in valueOf method calling when object is created. Loose equality is generally depended and solve like this in JS Here is an nice peice of discussion is present have an look here about this concept https://www.sololearn.com/Discuss/1861584/?ref=app here is another link which is nicely cooked and dished. https://codeburst.io/javascript-can-a-1-a-2-a-3-ever-evaluate-to-true-aca13ff4462d
22nd Feb 2020, 7:04 AM
DishaAhuja
DishaAhuja - avatar