Javascript Arrays
Array methods
let arr = ["a", "b", "c", "d", "e"];
slice()
I can define start parameter
slice(2) - second index of array is a start parameter
I can also define end parameter
slice(2,5) - second index of array is a start parameter, and fifth index of array is a end parameter
I can get last element of the array
slice(-2) - last two element
slice(1, -2) - start from second element without last two elements
splice()
arr.splice(2) - split from third element
arr.splice(-1) -
Leave a comment