Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
167
rated 0 times [  173] [ 6]  / answers: 1 / hits: 156724  / 11 Years ago, mon, september 23, 2013, 12:00:00

I have an array as :



items=[{'id':1},{'id':2},{'id':3},{'id':4}];


How should I add a new pair {'id':5} to the array?


More From » arrays

 Answers
17

Use .push:



items.push({'id':5});

[#75508] Saturday, September 21, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bradleymoisesy

Total Points: 121
Total Questions: 105
Total Answers: 95

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;