I am trying to learn JS. It seems simple but I am not sure how to do this.
having this javascript object based on this good
thread
var people = {
1: { name: 'Joe' },
2: { name: 'Sam' },
3: { name: 'Eve' }
};
How do I add the following value
4: { name: 'John' }
To get name Eve I write
people["1"].name
Assign the anonymous object to it the way you would any other value.
For what it’s worth, since your keys are numeric you could also use zero-based indices and make people an array.
and