Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

merge 2 array of object by key

let arr1 = [
    { id: "abdc4051", date: "2017-01-24" },
    { id: "abdc4052", date: "2017-01-22" }
];

let arr2 = [
    { id: "abdc4051", name: "ab" },
    { id: "abdc4052", name: "abc" }
];

let arr3 = arr1.map((item, i) => Object.assign({}, item, arr2[i]));

console.log(arr3);
 Run code snippet
Comment

js combine 2 array to object key value

var columns = ["Date", "Number", "Size", "Location", "Age"];
var rows = ["2001", "5", "Big", "Sydney", "25"];
var result =  rows.reduce(function(result, field, index) {
  result[columns[index]] = field;
  return result;
}, {})

console.log(result);
Comment

PREVIOUS NEXT
Code Example
Javascript :: axios get method 
Javascript :: js hoisting 
Javascript :: how to make a preloader dissapear in html 
Javascript :: cypress multiple true 
Javascript :: javascript hide elements by class 
Javascript :: Error: A Route is only ever to be used as the child of element, never rendered directly. Please wrap your Route in a Route 
Javascript :: jquery add class to body 
Javascript :: json db 
Javascript :: icon in react native 
Javascript :: bson to json converter 
Javascript :: tolowercase js 
Javascript :: is digit javascript 
Javascript :: node convert string to hash 
Javascript :: js create json from object 
Javascript :: what is the function of delete operator in javascript 
Javascript :: read image metadata javascript 
Javascript :: what is redis used for 
Javascript :: js sleep function with argument 
Javascript :: javascript update text in div 
Javascript :: identify primary colors in img with js 
Javascript :: react bootstrap button 
Javascript :: yarn add next auth 
Javascript :: python class json serializable 
Javascript :: discord js remove reaction from user 
Javascript :: check if variable is set javascript 
Javascript :: how to swap two elements in an array javascript 
Javascript :: get data from json placeholder 
Javascript :: local storage react 
Javascript :: update angular project 
Javascript :: pause javascript 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =