The problem is not with your code, but with alert
, which when passed an object will invoke its .toString()
method which typically reports [object Object]
. Try using console.dir()
instead.
As for your object itself, what you have when you use {}
is an object whose properties are equivalent to the keys of the associate arrays available in other languages, i.e.
var obj = {
path1: name1,
path2: name2,
...
};
It's not really an "array" at all.