Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

java script zip function

// Zipping two arrays into an object, better performance than map

let labels = ['a', 'b', 'c']
let values = [1, 2, 3]
let out = {}
for (var i = 0; i < labels.length; i++) {
    out = { ...out, [labels[i]]: values[i] }
 }
console.debug(out);
// { a: 1, b: 2, c: 3 }
 
PREVIOUS NEXT
Tagged: #java #script #zip #function
ADD COMMENT
Topic
Name
4+1 =