Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add new value to array of object javascript using spread

const initialArr = [
      {name: 'eve'},
      {name: 'john'},
      {name: 'jane'}
    ]

const newArr1 = initialArr.map(v => ({...v, isActive: true}))
const newArr2 = initialArr.map(v => Object.assign(v, {isActive: true}))

// Results of newArr1 and newArr2 are the same
Comment

PREVIOUS NEXT
Code Example
Javascript :: check cookie existence js 
Javascript :: scarping js 
Javascript :: ajax form submit 
Javascript :: Adding an item to an array 
Javascript :: audio get current time 
Javascript :: object properties 
Javascript :: is there an api for netflix shows 
Javascript :: use state in className 
Javascript :: remove item from array 
Javascript :: buffer image 
Javascript :: building an array of a numbers javascript 
Javascript :: python to java script 
Javascript :: react.createref 
Javascript :: currying function callback javascript 
Javascript :: hasOwnProperty.call js 
Javascript :: how to wait for the subscribe to finish before going back to caller method in angular 
Javascript :: math question 
Javascript :: jquery check if eleme 
Javascript :: use of parse in react 
Javascript :: apoolo uselaxyQuery bypass cache 
Javascript :: how to fetch web page source code with javascript 
Javascript :: get an day array when have a startDay and FinishDay js 
Javascript :: vuejs cordoba pantalla en blanco 
Python :: python int64index 
Python :: python open link in browser 
Python :: python wait 1 sec 
Python :: how to convert a column to datetime in pandas 
Python :: rotate picture in opencv2 python 
Python :: matplotlib equal axis 
Python :: conda create environment python 3.6 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =