A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.w3schools.com/jsref/jsref_slice_array.asp below:

Website Navigation


JavaScript Array slice() Method

JavaScript Array slice() Examples

Select elements:

const fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
const citrus = fruits.slice(1, 3);

Try it Yourself »

Select elements using negative values:

const fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
const myBest = fruits.slice(-3, -1);

Try it Yourself » Description

The slice() method returns selected elements in a new array.

The slice() method selects from a given start, up to a (not inclusive) given end.

The slice() method does not change the original array.

Syntax Parameters Parameter Description start Optional.
Start position. Default is 0.
Negative numbers select from the end of the array. end Optional.
End position. Default is last element.
Negative numbers select from the end of the array. Return Value A new array containing the selected elements. Browser Support

slice() is an ECMAScript1 (JavaScript 1997) feature.

It is supported in all browsers:

Chrome Edge Firefox Safari Opera IE Yes Yes Yes Yes Yes Yes

Track your progress - it's free!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4