How do I create nested elements in Javascript object through dot notation only? like
a= {};
a.b = 100; //is valid
a.x.y = 200; //is invalid?
How do I create nested elements in Javascript object through dot notation only? like
a= {};
a.b = 100; //is valid
a.x.y = 200; //is invalid?
The 3rd is invalid as a.x is undefined.
And you are trying to set a value to a undefined property
a= {};
a.b = 100; //is valid
a.x = {};
a.x.y = 200; // This works
a = { b: 100, x: { y: 200 } }. You can nest arrays, other objects or assign functions, numbers or strings to each property. With proper indentation this way of defining a complex structure can be very clear.