if you wanted to remove the last item in an array you would want to use pop() method. This removes the last item from an array but also returns it.
example:
var array = [1, 2, 3];
var last = array.pop([2]);
This removes the last item from the array "3" then save's 3 in the var last. If you wanted to use it later.
Similarly the shift() method does the same for the beginning of an array.
No comments:
Post a Comment