Skip to content

JSArray.Slice

boxgaming edited this page Jul 25, 2026 · 3 revisions

Returns a copy of a portion of an array into a new array object selected from a specified starting and ending index.

Syntax

newArray = JSArray.Slice ( a, start% [, end%] )

Parameters

  • The a parameter contains the native JavaScript array on which the operation will be performed.
  • The start% parameter indicates the zero-based index at which to start extraction. If not specified, all elements to the end of the array will be exctracted.
  • The optional end% parameter indicates the zero-based index at which to end extraction.

Example

Import JSArray From "lib/lang/array.bas"

Dim animals As Object
animals = JSArray.Create("ant", "bison", "camel", "duck", "elephant")

Print JSArray.Slice(animals, 2)
Print JSArray.Slice(animals, 2, 4)
Print JSArray.Slice(animals, 1, 5)

Output

camel,duck,elephant
camel,duck
bison,camel,duck,elephant

See Also

JSArray.Create
JSArray.Splice
JavaScript - Array.slice()

Clone this wiki locally