3 ms·
Interesting, I didn't know about `[1] == true`, `[0] == false` family of equalities. Edit: it seems more general, `42 == [42]` etc. holds. Edit: more fun (
by jakub_g 12y ago
Interesting, I didn't know about `[1] == true`, `[0] == false` family of equalities.
Edit: it seems more general, `42 == [42]` etc. holds.
Edit: more fun
([0])==false // true
!([0])==false // true
- serve_yay 12y agoI am not sure what's up with the first two. But in the latter one, I believe the array is being coerced to a string, which is its contents separated by commas, so in this case just "42". Then either the left-hand 42 is coerced to a string or the right-hand "42" is coerced to a number, I'm honestly not sure. It hasn't been all that long since I read the spec about this, either. Sheesh.
- deleted 12y ago[deleted]
- ricardobeat 12y agoTranslation: "0" == 0 false == false