How to change indexes keys an array of object in JavaScript - Stack Overflow

PHOTO EMBED

Tue Jun 27 2023 07:17:39 GMT+0000 (Coordinated Universal Time)

Saved by @Minhow #javascript

const names = [{name:'abc'},{name:'def'},{name:'ghi'}];
const entries = Object.fromEntries(names.entries());
const mappedNames = Object.keys(entries).map(key => [`string${key}`, entries[key]])

const newNames = Object.fromEntries(mappedNames)
content_copyCOPY

https://stackoverflow.com/questions/64800465/how-to-change-indexes-keys-an-array-of-object-in-javascript