Skip to content

Instantly share code, notes, and snippets.

@hamzahamidi
Created July 24, 2019 15:34
Show Gist options
  • Save hamzahamidi/13d96a707f7ca43e1d502d995a9349ec to your computer and use it in GitHub Desktop.
Save hamzahamidi/13d96a707f7ca43e1d502d995a9349ec to your computer and use it in GitHub Desktop.
difference between slice splice & pop in javascript
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