5 ms·
I get the impression you don't know JS any better than I do. [] and {} seem to be identical, except that [] one auto-increments a key-as-string in its initiali
by s3graham 17y ago
I get the impression you don't know JS any better than I do.
[] and {} seem to be identical, except that [] one auto-increments a key-as-string in its initialization syntax.
Yes, an _ before the string would fix that particular interactive session, but it's not going to work in general.
- invisible 17y ago[] creates an Array (a special instance of an Object which has a completely different prototype). {} creates an Object with no special methods except ones that apply to all types in JavaScript. I'm pretty good at JS - I swear. In general, most don't use the same String value for a key/index to store different values. Just my opinion on that one, though. Oh, and: you can use Firebug to effectively see the difference between the two. >>> x = ["1"]; ["1"] >>> x = {"1": "1"}; Object 1=1
- s3graham 17y ago> I'm pretty good at JS - I swear. Sorry, didn't mean to be a dick. :) This particular wart apparently got my nerd rage going. > In general, most don't use the same String value for a key/index to store different values Agreed, it'd generally be pretty sketchy. My current puttering around project is a "Python-in-JS" in the vein of http://objective-j.org/ http://objective-j.org/ which is where the desire for a "map" rather than an "object" comes from.