My current array: abc = ['a', 'b', 'c', 'd'];
I understand .pop()
remove and returns the last item of an array, thus: abc.pop(); = 'd'
However, I want to remove the last item, and return the array. So it would return:
['a', 'b', 'c'];
Is there a JavaScript function for this?
pop()
function also removes last element from array, so this is what you want(Demo on JSFiddle):
var abc = ['a', 'b', 'c', 'd'];
abc.pop()
alert(abc); // a, b, c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With