Every object in JavaScript is implemented as an object hash, so there is no functional difference.
For example, check out this test:
var arr = [];
arr[5] = 5;
arr['5'] = 'not 5';
console.log(arr.length, arr);
// output: 6 [undefined, undefined, undefined, undefined, undefined, "not 5"]
Numbers are stringified when used as positions.
See Crockford's website about JavaScript for more information. The especially important part is under the heading "Arrays":
Arrays in JavaScript are also hashtable objects.
Performance isn't really an issue unless you have a ton of objects to keep track of (like 500,000+), in which case you're probably doing something wrong.
There are optimizations you can do, but they don't really make sense unless you're doing something unnatural with JavaScript (like compression algorithms... I worked on an LZMA implementation in JS... bad idea).
Note:
If you have a spare set (like you define only 10 indexes out of 10,000), you should probably be using a regular object. Arrays will initialize all 10,000 indexes to 'undefined', whereas Object.keys(obj)
will only report the 10 you have set. This is a minor optimization that actually makes sense.