Courses / JavaScript
52. Array.prototype.slice()
Returns a shallow copy of a portion of an array into a new array object.
1 min read Chapter 52 of 99
JavaScript
Array.prototype.slice()
Array.prototype.slice() creates a new array by copying a portion of an existing array.
"I need a part of my array without changing the original."
The `slice()` method returns a shallow copy of a section of an array into a new array object, without modifying the original array. You can specify the start and end indices to determine which elements to copy.
"I need a part of my array without changing the original."
The `slice()` method returns a shallow copy of a section of an array into a new array object, without modifying the original array. You can specify the start and end indices to determine which elements to copy.