Skip to content

Instantly share code, notes, and snippets.

@sandeshdamkondwar
Created May 4, 2015 20:11
Show Gist options
  • Save sandeshdamkondwar/2ecf091ce093fe48add0 to your computer and use it in GitHub Desktop.
Save sandeshdamkondwar/2ecf091ce093fe48add0 to your computer and use it in GitHub Desktop.
splice and slice
array1 = [0,1,2,3,4,5,6]
[0, 1, 2, 3, 4, 5, 6]
array1.splice(2) -> default first argument is 0
[2, 3, 4, 5, 6]
array1
[0, 1]
----------------------------------------------------------------------------------------
array1 = [0,1,2,3,4,5,6]
[0, 1, 2, 3, 4, 5, 6]
array1.splice(0, 2)
[0, 1]
array1
[2, 3, 4, 5, 6]
----------------------------------------------------------------------------------------
array1 = [0,1,2,3,4,5,6]
array1.slice (2, 3)
[2]
array1.slice(3)
[3, 4, 5, 6]
----------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment