+ 3
Explain these conditions in JS?
(0=="0") is true. (0==[ ]) is true. ("0"==[ ]) is false. Why? https://code.sololearn.com/WN384S96WWIU/?ref=app
2 odpowiedzi
+ 2
0 == "0" is true because "0" string converted to number is 0
0 == [ ] is true because empty arrays and empty strings are treated as false, and so is 0 (then false == false)
"0" == [ ] is false because non empty strings are treated as true and empty array as true (then true != false)
+ 2
Thanks Akash.
https://code.sololearn.com/WhIjDEFTu8Uz/?ref=app