The .slice() method can be used on code example
Example 1: use of slice and splice add elements array
function frankenSplice(arr1, arr2, n) {
let combinedArrays = arr2.slice()
combinedArrays.splice(n, 0, ...arr1)
return combinedArrays
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
Example 2: array.slice
const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
console.log(animals.slice(2));
console.log(animals.slice(2, 4));
console.log(animals.slice(1, 5));
Example 3: slice()
/"slice() copies or extracts a given number of elements to a new array"/
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];
let todaysWeather = weatherConditions.slice(1, 3);
Example 4: array.slice in typescript
arr.slice([start[, end]])