Reputation: 251
question guys, I have this type of object:
activities: Object
activitiy: some activity
date: some date
level: some level
what I am trying to achieve here is to make it like this
activities: Array[1]
[0]Object
then what i want to do is push to the array of activities
activities.push(newobject);
This is not the right logic:
activities = $.map(myObj, function(value, index) {
return [value];});
So what should I do to achieve what I want. Above will just put each value of the object as an array value instead of the whole object itself.
Upvotes: 1
Views: 27
Reputation: 31712
Try:
activities = [activities];
to transform activities
into an array that initially contains the original object. Then you can push new items into activities
since it's now an array.
Upvotes: 2