Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

change key name in array of objects javascript

const arrayOfObj = [{
  key1: 'value1',
  key2: 'value2'
}, {
  key1: 'value1',
  key2: 'value2'
}];
const newArrayOfObj = arrayOfObj.map(({
  key1: stroke,
  ...rest
}) => ({
  stroke,
  ...rest
}));

console.log(newArrayOfObj);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #key #array #objects #javascript
ADD COMMENT
Topic
Name
9+7 =