Comment by idle_zealot
Comment by idle_zealot 17 hours ago
Huh. I always thought that JS objects supported string and number keys separately, like lua. Nope!
[Documents]$ cat test.js
let testArray = [];
testArray[0] = "foo";
testArray["0"] = "bar";
console.log(testArray[0]);
console.log(testArray["0"]);
[Documents]$ jsc test.js
bar bar
[Documents]$
Lua supports even functions and objects as keys:
Functions as keys is handy when implementing a quick pub/sub.