how do i create a new array if my arrays have the same id in React
I'm confused about processing the array into 2 arrays if he has the same id, then what are the right steps so I can find a way out?
my array
array = [
{
name : 'foo1',
id_ : 3451,
statuse : true
},
{
name : 'foo2',
id_ : 3451,
statuse : false
},
{
name : 'foo3',
id_ : 3452,
statuse : false
},
{
name : 'foo1',
id_ : 3452,
statuse : true
},
]
and the results I want
result = [
[
{
name : 'foo1',
id_ : 3451,
statuse : true
},
{
name : 'foo2',
id_ : 3451,
statuse : false
},
],
[
{
name : 'foo3',
id_ : 3452,
statuse : false
},
{
name : 'foo1',
id_ : 3452,
statuse : true
},
]
]
question from:
https://stackoverflow.com/questions/65890193/how-do-i-create-a-new-array-if-my-arrays-have-the-same-id-in-react 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…