push in a dict js code example
Example 1: javascript add to a dictionary
for (var i = 0; i < input.length; i++) {
var datum = input[i];
if (!d[datum.key]) {
d[datum.key] = [];
}
d[datum.key].push(datum.val);
}
Example 2: javascript add to a dictionary
var d = {}
for (var i in input) {
var datum = input[i];
d[datum.key] = datum.val
}