js list slice code example
Example 1: 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);
// todaysWeather equals ['snow', 'sleet'];
// weatherConditions still equals ['rain', 'snow', 'sleet', 'hail', 'clear']
Example 2: js slice
const arr=[1,2,3,4,5];
const slicedArr = arr.slice(1,4); // slicedArr = [2,3,4]