How to push latest value into object array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to push latest value into object array

I have a array object like below [{'year:' 2008, 'occ': 1},{'year:' 2009,'occ:' 1},{'year :' 2008, 'occ:' 2}] Output [{'year:' 2009,'occ:' 1},{'year :' 2008, 'occ:' 2}]

11th Aug 2016, 10:35 AM
Gayathri
2 Answers
0
Looking to pop off the first element?
11th Aug 2016, 5:24 PM
SouthBay
SouthBay - avatar
0
The function "yourArrayName.shift();" will do this easily.
12th Aug 2016, 3:42 PM
SouthBay
SouthBay - avatar