jquery array slice splice code example
Example 1: javascript slice vs splice
var array=[1,2,3,4,5]
console.log(array.slice(2));
console.log(array.slice(-2));
console.log(array);
var array2=[6,7,8,9,0];
console.log(array2.slice(2,4));
console.log(array2.slice(-2,4));
console.log(array2.slice(-3,-1));
console.log(array2);
Example 2: splice javascript
const months = ['Jan', 'March', 'April', 'June'];
months.splice(1, 0, 'Feb');
console.log(months);
months.splice(4, 1, 'May');
console.log(months);
months.splice(0, 1);
console.log(months);