1const str = 'The quick brown fox jumps over the lazy dog.';
2
3console.log(str.slice(31));
4// expected output: "the lazy dog."
5
6console.log(str.slice(4, 19));
7// expected output: "quick brown fox"
1const str = 'The quick brown fox jumps over the lazy dog.';
2
3console.log(str.slice(31)); // expected output: "the lazy dog."
4
5console.log(str.slice(4, 19)); // expected output: "quick brown fox"
6
7console.log(str.slice(-4)); // expected output: "dog."
8
9console.log(str.slice(-9, -5)); // expected output: "lazy"
10
11// source : https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/String/slice
1const arr=[1,2,3,4,5];
2
3const slicedArr = arr.slice(1,4); // slicedArr = [2,3,4]