Re:Even experts get it wrong
by StavrosK on Tuesday July 24, 2012 @10:38AM
(#4285847)
This is irrelevant, but it blows my mind that "[1] == [1]" returns False in JS.
[ Parent
| on HN ]
I'm "ok" with that, it's a property of non-overridable equality tests, where arrays are "standard objects" (with natively implemented lots of things, but still objects) rather than built-in magical special cases of the language (although there are still things done by arrays I don't think you can do without recent extensions to the spec, such as
js> var a = []
js> a[42] = 3
3
js> a.length
43
) as opposed to e.g. Go where a few blessed types have access to features Go users do not have any possible access to.It bothers me significantly more that
[1] == 1
does not return false in JS. Although the rules through which this is reached are clear.