sry if this question is still there but i searched for it and i didn´t find a solution. Also i couldn´t get any hint out of the Developer.Mozilla website where Objects.assign etc. is described well.
The question:
How can i change the children of an object? With exactly the output i described in the following.
Sample-Code
var obj= {test: [{a: 2}, {b: 3}]};
var newChildren = [{a: 3}, {b: 5}, {c: 1}];
//I read the obj key value by the following:
var objKey = Object.entries(obj)[0][0]
//Here i want to have some code to get the following result
//My momentary regarding to @webdeb
var output = Object.assign({}, {objKey: newChildren})
actual output: // {objKey: [{a: 3}, {b: 5}, {c: 1}]}
wanted output: // {test: [{a: 3}, {b: 5}, {c: 1}]}
I have no other option to get the code in some other format so the "input" is needed in the way i described. And i need to set the objKey
as a variable, because i have multiple keys in my code wich i have to set for multiple children. (Doing some filter stuff)
Thanks for your help
BR Jonathan