Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add two attay into object in javascript

var keys = ['foo', 'bar', 'baz'];
var values = [11, 22, 33]

var result =  Object.assign.apply({}, keys.map( (v, i) => ( {[v]: values[i]} ) ) );
console.log(result); //returns {"foo": 11, "bar": 22, "baz": 33}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #attay #object #javascript
ADD COMMENT
Topic
Name
5+9 =