-2

I have an object of objects as follows:

var people = {
"fred": {"height": 10, "weight": 190},
"mary": {"height": 6, "weight": 120}
};

I want to add another item to this object. Specifically, I want to add the following object:

var luke = {"height": 8, "weight": 130};

Why can't I just do so using people.push? such as:

people.push(luke)
J-B-L
  • 55
  • 1
  • 6

1 Answers1

1

You should do

 people["luke"] = luke

or

 people.luke = luke
Soren
  • 14,402
  • 4
  • 41
  • 67