It's even tagged "bad-theory." I think it's pretty clearly a joke! A really good one!
http://www.computer.org/csdl/mags/co/2012/02/mco2012020007.p...
for (k in ['a', 'b']) {
console.log(k);
}
and get back 0, 1? However: var a = {0:'a', 1:'b'};
for (k in a) {
console.log(k);
}
also outputs 0, 1.Edit: turns out, you can even have doubles, too:
var weird = {3.14:'hello', 6.28:'world'};
// for loop above emits: 3.14, 6.28
console.log(weird[3.14]); // emits 'hello'That's because Javascript doesn't actually have integers, it just has "Number":
> The Number type has exactly 18437736874454810627 (that is, 264−253+3) values, representing the double-precision 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic
ok, the last paragraphs kind of give it away... but there are good points in terms of keeping the data flat