avascript slice () dengan indeks negatif

Negative Index Slice in JavaScript
let programmingLangs = ["JavaScript", "Python", "C#", "Java", "PHP", "Node"];

// Slice the last 4 elements in an array
let arr1 = programmingLangs.slice(-4)
console.log("Last 4 elements will be sliced", arr1)

//Slice array from index start to second last
let arr2 = programmingLangs.slice(1, -1)
console.log("Array will be sliced from Index 1 to second last", arr2) //Note the end is -1 and that index will not be sliced
Gorgeous Gazelle