Created
July 24, 2019 15:34
-
-
Save hamzahamidi/13d96a707f7ca43e1d502d995a9349ec to your computer and use it in GitHub Desktop.
difference between slice splice & 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
let array_1 = [1,2,3,4]; | |
let array_2 = [1,2,3,4]; | |
let array_3 = [1,2,3,4]; | |
array_1.splice(-1,1) // output --> [4] array_1 = [1,2,3] | |
array_2.slice(0,-1); // output --> [1,2,3] array_2 = [1,2,3,4] | |
array_3.pop(); // output --> 4 array_3 = [1,2,3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment