Answers for "combine the values of 2 arrays in key = value jquery"

0

combine the values of 2 arrays in key = value jquery

var keys = ['a', 'b', 'c'],
    values = [1, 2, 3],
    associated = keys.reduce(function (previous, key, index) {
        previous[key] = values[index];
        return previous
    }, {})

console.log(associated) // Object {a: 1, b: 2, c: 3}
Posted by: Guest on April-16-2021

Code answers related to "combine the values of 2 arrays in key = value jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language