3 Answers
+ 6
Reasons: First of all, == operator checks if "values" are equal or not! 1. (0 == "0") As 0(int) is equal to 0(string). Hence evaluates to true! 2. (0 == [ ]) here 0 has no value i.e., it behaves as false value and so is the [ ] array. Hence alerts true! 3. ("0" == [ ]) - most interesting ;) "0" is defined i.e., it has a true value, whereas as above mentioned [ ] acts as a false value. So, the whole statement evaluates to false! Hope you understood :)
3rd Apr 2018, 5:05 PM
777
777 - avatar
+ 2
(0 === "0"); //FALSE === compare also type, an INT is not a STRING
4th Apr 2018, 2:47 AM
Jan Rucki
Jan Rucki - avatar
+ 2
== doesnt look to the type so 0 and "0" are equal but === looks to the type and 0==="0" is not true(false😂) if you want to know if something has the same type and value use ===
4th Apr 2018, 4:36 PM
Daimondweter
Daimondweter - avatar