๐Ÿ“šย Reference


๐Ÿ“œ Chapter


splice()

slice()


arr.slice([begin[, end]]);

๋ฐฐ์—ด๋ณ€์ˆ˜๋ช….slice('์ถ”์ถœํ•  ์‹œ์ž‘ ์ธ๋ฑ์Šค', '์ถ”์ถœ์„ ์ข…๋ฃŒํ•  ์ธ๋ฑ์Šค');
arr.slice()

์˜ˆ์‹œ


const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];

console.log(animals.slice(2));
// ["camel", "duck", "elephant"]

console.log(animals.slice(2, 4));
// ["camel", "duck"]

console.log(animals.slice(1, 5));
// ["bison", "camel", "duck", "elephant"]

console.log(animals.slice(-2));
// ["duck", "elephant"]

console.log(animals.slice(2, -1));
// ["camel", "duck"]

console.log(animals.slice());
// ["ant", "bison", "camel", "duck", "elephant"]