I have an array in javascript
var myArr = {
'textId':'123',
'type':'animal',
'content':'hi dog',
'expires':'27/10/2012'
};
$.each(myArr, function(myArrArrKey, myArrArrValue){
console.log( myArrArrValue );
});
The above console prints following values
123
app
hi app
27/10/2012
Now i am want to append an element to the existing array, i am trying to do like the below one
myArrValue.push({'status':'active'});
The above push throws following error
TypeError: Object #<Object> has no method 'push'
Kindly help me how to append to that existing array element.
I want to print the array like
123
app
hi app
27/10/2012
active
this isn’t an array, it’s an object!
this isn’t necessary with jQuery
easier would be
to add new entries to your “array”
or
to remove entries from your “array”
or
FYI:
myArrValue.push({'status':'active'});wont work. myArrValue isn’t the “array” itself and also not an array having the methodpush.If it would be an array the result would be, that your latest entry is the whole an object
{'status':'active'}