arrays - javascript operator "in" -
i'm used python, so
a = [1,2,3] 1 in # -> true b = ["1", "2", "3", "x"] "x" in b # -> true why in javascript
a = [1,2,3] 1 in // -> true b = ["1", "2", "3", "x"] "x" in b // -> false and weirder
"1" in b // -> true
in works on keys of arrays, not values. 1 in a succeeds because there element #1 in array, 2 value.
"1" fails, because there no 1 property or key in array.
details here: https://developer.mozilla.org/en/javascript/reference/operators/in
Comments
Post a Comment