Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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} 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #combine #values #arrays #key #jquery
ADD COMMENT
Topic
Name
6+5 =