You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! The issue you are seeing there with [0] is not an issue at all. The behaviour is completley normal if you embrace JS coercion (implicit casting) in == operator.
the issue is that in the expression [0] == false, false is actually coerced to a Number by the built-in object Number, and of course: Number(false) is 0!
Then, [0] is first coerced to the String "0" and finally coerced to the Number 0.
So, the last comparision is actually 0 === 0. Which is obviously true.
Hope the explanation shed some light on the subject!
The text was updated successfully, but these errors were encountered:
Hey! The issue you are seeing there with [0] is not an issue at all. The behaviour is completley normal if you embrace JS coercion (implicit casting) in
==
operator.the issue is that in the expression
[0] == false
,false
is actually coerced to a Number by the built-in objectNumber
, and of course:Number(false)
is 0!Then,
[0]
is first coerced to the String"0"
and finally coerced to the Number0
.So, the last comparision is actually 0 === 0. Which is obviously true.
Hope the explanation shed some light on the subject!
The text was updated successfully, but these errors were encountered: