How can I make an Object that holds arrays as element. I tried that:
var dMap = new Object();
...
if (dMap[d.name] === undefined) {
dMap[d.name] = p.name;
} else {
dMap[d.name].push(p.name);// It gives error here
}
...
How to do that?
Initially add an array, by adding square brackets around your variable:
Also, to test whether a variable/property is defined or not, use
typeof variable == "undefined", becauseundefinedcan be overwritten by anything, causing the comparison to break: