Created
May 4, 2015 20:11
-
-
Save sandeshdamkondwar/2ecf091ce093fe48add0 to your computer and use it in GitHub Desktop.
splice and slice
This file contains hidden or 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
| 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