Nice !
how to convert something having more than one value of id like below : for this example i understand there wont be more than one id but in my case there will be same value.
[ { id: 111, name: 'John', age: 29 }, { id: 111, name: 'Rob', age: 29 }, { id: 111, name: 'Joe', age: 29 }, { id: 112, name: 'Sarah', age: 25 }, { id: 122, name: 'Kate', age: 22 }, { id: 123, name: 'Tom', age: 21 }, { id: 125, name: 'Emma', age: 24 }, ],
to
{ 111:[{ id: 111, name: 'John', age: 29 },{ id: 111, name: 'Rob', age: 29 },{ id: 111, name: 'Joe', age: 29 }] 112:{ id: 112, name: 'Sarah', age: 25 }, 122:{ id: 122, name: 'Kate', age: 22 }, 123:{ id: 123, name: 'Tom', age: 21 }, 125:{ id: 125, name: 'Emma', age: 24 } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice !
how to convert something having more than one value of id like below :
for this example i understand there wont be more than one id but in my case there will be same value.
to
{
111:[{ id: 111, name: 'John', age: 29 },{ id: 111, name: 'Rob', age: 29 },{ id: 111, name: 'Joe', age: 29 }]
112:{ id: 112, name: 'Sarah', age: 25 },
122:{ id: 122, name: 'Kate', age: 22 },
123:{ id: 123, name: 'Tom', age: 21 },
125:{ id: 125, name: 'Emma', age: 24 }
}