News for hackers. Stuff that matters.
Re:JavaScript Errors: An Exceptional History by dlbucci on Tuesday November 05, 2019 @10:51AM (#21453421)
I had no idea JavaScript shipped without Arrays. Too bad they didn't just let objects take anything as a key, like in Lua. Then you wouldn't have all the edge cases Arrays cause in JS. Oh well!
Re:JavaScript Errors: An Exceptional History by rodinia on Tuesday November 05, 2019 @11:41AM (#21453986)
This (anything can be a key) was eventually added with the Map class. They're an iterable type too, so they're much more useful than Objects imo.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re:JavaScript Errors: An Exceptional History by dlbucci on Tuesday November 05, 2019 @12:55PM (#21454768)
I agree! They are more useful! That's why I wish objects behaved that way to begin with!
Re:JavaScript Errors: An Exceptional History by gnode on Tuesday November 05, 2019 @11:10AM (#21453614)
> Too bad they didn't just let objects take anything as a key

They do, except they get coerced to strings in whacky ways. Objects can be used largely like arrays, and Arrays are Objects, but Array is more suited for an ordered collection of numerically indexed elements, and so has relevant properties and methods, like length and indexOf.

Re:JavaScript Errors: An Exceptional History by dlbucci on Tuesday November 05, 2019 @12:58PM (#21454811)
Yeah, but the weirdness inherent to them being objects but also not objects leads to all sorts of bullcrap, like `Array.isArray` being a thing. I greatly prefer the Lua approach where you only have one map type (tables), and there are methods that allow you to easily use the tables as an array.
Re:JavaScript Errors: An Exceptional History by tdy_err on Wednesday November 06, 2019 @09:54AM (#21463132)
The initial v1 JavaScript was written in about ten days:

https://thenewstack.io/brendan-eich-on-creating-javascript-i...