Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. function shiftArray(arr) {
  2. // remove 1 item at 0-index position, return the deleted item
  3. return arr.splice(0, 1);
  4. }
  5.  
  6. var a = [1, 2, 3];
  7.  
  8. var b = a.shift();
  9.  
  10. console.log(a); // [2, 3]
  11.  
  12. console.log(b); // 1
  13.  
  14. var c = shiftArray(a);
  15.  
  16. console.log(a); // [3]
  17.  
  18. console.log(c); // [2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement