1var arr = [1, 2, 3, 4];
2var theRemovedElement = arr.shift(); // theRemovedElement == 1
3console.log(arr); // [2, 3, 4]
1var myarray = ["item 1", "item 2", "item 3", "item 4"];
2
3//removes the first element of the array, and returns that element.
4alert(myarray.shift());
5//alerts "item 1"
6
7//removes the last element of the array, and returns that element.
8alert(myarray.pop());
9//alerts "item 4"