{
Name: "2020 collection,"
Selected: true,
Children:
{
Id: 1,
Selected: true,
Name: "summer",
},
{
Id: 2,
Selected: true,
Name: "autumn",
}
]
}
]
CodePudding user response:
The function changeSelected (source) {
Source. The forEach (item=& gt; {
Item. The selected & amp; & (item. Selected=false)
Item. Children & amp; & ChangeSelected (item. Children)
})
}
ChangeSelected (newArr)
The console. The log (newArr)
If don't want to change newArr directly, it will first newArr deep copy a perform again