Re:Fun with JavaScript Arrays
by dkroy on Wednesday June 12, 2013 @09:30AM
(#5867934)
Couldn't some JavaScript Objects be called associative arrays?
[ Parent
| on HN ]
Not really no. Every object has it's prototype set to the object prototype. Which means that even if you create a new empty object, it inherits functions and values from the object protype.
var a = {}; typeof(a.hasOwnProperty) === "function"
Objects are very often used as associative arrays, quite simply becouse objects and arrays are all js has to offer. Javascript Harmony will change that though, with it's own Map type.
Not really. Actually you can create an empty object by:
var a = Object.create(null)