Favorites

JavaScript Array.prototype.slice() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Array.prototype.slice()
JavaScript Array Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The slice() method returns a copy of part of an array, from a start index up to an end index, without changing the original.

Description

The slice() method returns a shallow copy of a portion of an array, from start up to but not including end. The original array isn't changed. Negative indexes count back from the end, so slice(-2) gives the last two elements, and slice() with no arguments copies the whole array.

Don't confuse it with splice(), which removes or inserts elements in place.

Copying an array with slice() is shallow: objects inside are shared between the original and the copy. slice() is also commonly used to convert array-like objects, as in Array.prototype.slice.call(arguments) in older code, although Array.from() is the modern way. Strings and typed arrays have slice() methods that work the same way.

Syntax

array.slice()
array.slice(start)
array.slice(start, end)

Parameters

  • startOptional. The index to start at. Negative values count from the end. Defaults to 0.
  • endOptional. The index to stop before. Negative values count from the end. Defaults to the length.

Return Value

A new array containing the extracted elements.

Example

const animals = ['ant', 'bison', 'camel', 'duck', 'elephant'];
console.log(animals.slice(2));
console.log(animals.slice(1, 3));
console.log(animals.slice(-2));
console.log(animals.length);   // unchanged

Browser Support

The following information will show you the current browser support for the Array.prototype.slice() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee