let new_json = {
sessions: []
};
new_json.sessions[0]["timing"] = []
Error:
VM73:1 Uncaught TypeError: Cannot set property 'timing' of undefined
at <anonymous>:1:32
(anonymous) @ VM73:1
Here I am trying to add data to one index of the array
But, getting above error while doing this.
Is there any way to do this?
Please have a look
0. Sonew_json.sessions[0]will giveundefined. This results in an error when you try and set a property of"timing"onundefined. Instead, you can set the value of index0to be an object literal, with the property of timing and an array value. Or, initialize your sessions array with an empty object[{}]