3 ms·
I used [] because I hoped it would correctly handle number indices. But, I originally used {}. The auto-stringification of the keys was my complaint.
by s3graham 17y ago
I used [] because I hoped it would correctly handle number indices. But, I originally used {}. The auto-stringification of the keys was my complaint.
- axod 17y agoAll keys are strings :/ What you're complaining about is similar to complaining that "hello " + 3 + " world" == "hello " + "3" + " world"
- invisible 17y agoWhen assigning a String with a numeric value I think JavaScript treats it as a numeric for an Array and a String for regular Objects. This doesn't really change the difference, just that an Array should hold numerical index values (vs an Object key, but they CAN hold regular keys since they are an Object). A bit confusing I guess...