3 ms·
This is irrelevant, but it blows my mind that "[1] == [1]" returns False in JS.
by StavrosK 14y ago
This is irrelevant, but it blows my mind that "[1] == [1]" returns False in JS.
- masklinn 14y agoI'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.