combine the values of 2 arrays in key = value jquery code example
Example: 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}