I'm fairly new to javascript and I just started learning about objects & arrays. I have an object like this:
var myObj= {'1'{ID:'1',x:200,y:300},
'2'{ID:'2',x:100,y:100}};
I'm willing to create another object inside the existing object("myObj") so that I can access it's properties using myObj['key'].x
.
Assume that I want to add the object {ID:'3',x:100,y:200}
into myObj and access it's property values using myObj[3].x
, myObj[3].y
etc., I know that .push
only works for arrays so I'm out of options.