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}var keys = ['foo', 'bar', 'baz'];
var values = [11, 22, 33]
var result = {};
keys.forEach((key, i) => result[key] = values[i]);
console.log(result);
Also in JavaScript:
- json-server localhost
- nodejs btoa
- discord.js reply to message
- javascript test for empty object
- button style in jquery datatable
- How can I get or extract some string part from url jquery
- document.addEventListener("backbutton
- npm package for sorting in reactjs
- checking object is empty in JS
- variables in js
- how to select the first div in jQuery
- classList has class
- sorting number with coma datatable
- momentjs utcoffset
- summernote mentions ajax
- format money javascript commas
- jquery 2 decimal places
- palindrome string js
- vuejs
- sendfile express syntax
- javascript assign value to input using name
- url redirect javascript
- prevent default on enter press
- JS truthy value of void