Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

change property name of object in array javascript

const columns = [
    { name: 'OrderNumber', title: 'Order Number' },
    { name: 'strawberry', title: 'Strawberry' },
    { name: 'vanilla', title: 'Vanilla' }
];

const newColumns = columns.map( item => {
  const { name: value, ...rest } = item;
  return { value, ...rest }
 }
);

console.log( newColumns );
 Run code snippet
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #property #object #array #javascript
ADD COMMENT
Topic
Name
3+3 =