I am creating an object from the array of objects, using the value for one of the keys:
const myArray = [
{
uuid: '123',
name: 'abc'
},
{
uuid: '789',
name: 'xyz'
}
];
const newObj = {};
for (var i = 0; i < myArray.length; i++) {
newObj[myArray[i].uuid] = myArray[i];
}
console.log('result: ', newObj)
how can I do the same using ecma6 practices?
forEachon the array (which would have worked in ES5 too). That’s about it for base JavaScript.