Answers for "javascript add to a dictionary"

0

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);
}
Posted by: Guest on May-30-2020
0

javascript add to a dictionary

var d = {}

for (var i in input) {
    var datum = input[i];
    d[datum.key] = datum.val
}
Posted by: Guest on May-30-2020
0

javascript add to a dictionary

obj["key3"] = "value3";
Posted by: Guest on May-30-2020

Code answers related to "javascript add to a dictionary"

Code answers related to "Javascript"

Browse Popular Code Answers by Language