javascript - push an assoc object into array -


says that I have done this:

  var user = [{id I use push to insert (': 1', 'gender': 'male'}, {'id': 2, 'gender': 'female'}]   

{'Id': 2, 'gender': 'female'}] I tried

  User [0]. Push ({'Swami': true});   

But it does not work tht the way.

You are not pushing an object in an array, you are pushing an object into an object .
You can do it by using the jquery method

  var object = $ Expansion ({}, object 1, object 2);    

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -