The following works but I'm trying to find a way to omit the arrayOfObjects[1]['testParent'] = {} bit, imagine you wanted to add a value to an empty object that is nested 10 levels down, you would have to initialize each level with an empty {} first, I'm trying to find a workaround for that.
let arrayOfObjects = [
{},
{},
{},
]
arrayOfObjects[1]['testParent'] = {}
arrayOfObjects[1]['testParent']['testKey'] = 'testValue'
// is there a way to do the above in one line, without having to initialize testParent with an empty object on line 7?
console.log(arrayOfObjects)
arrayOfObjects[1]['testParent'] = {'testKey': 'testValue'}, like this?