Created
January 30, 2012 23:34
-
-
Save karlwestin/1707528 to your computer and use it in GitHub Desktop.
Shift, unshift, push, pop in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [1,2,3,4,5,6,7]; | |
var first = arr.shift(); // first = 1, arr = [2,3,4,5,6,7] | |
arr.unshift(0); // arr = [0,2,3,4,5,6,7] | |
arr.push(8); // arr = [0,2,3,4,5,6,7,8] | |
var last = arr.pop() // last = 8, arr = [0,2,3,4,5,6,7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment