How to separate the Array to objects,
Need to convert the following
arr = [
{ name: 'abc', age: 15, roll_no: 25 },
{ name: 'def', age: 10, roll_no: 20 },
{ name: 'xyz', age: 16, roll_no: 18 },
];
Expected Output :
arr = [ abc : { name: 'abc', age: 15, roll_no: 25 },
def : { name: 'def', age: 10, roll_no: 20 },
xyz : { name: 'xyz', age: 16, roll_no: 18 }]
Kindly help me in this. Thanks in Advance
3
Answers
we can do this via
forEach
though not an efficient way