slice Method

Top  Previous  Next

Returns the selected elements in an array, as a new array object.

Syntax

String.slice(number1,number2)

Arguments

number1A number which specifies where to start the selection.
number2A number which specifies where to end the selection.

Return Value

A new array containing the selected elements.

Remarks

The first element in the initial array has index 0. Use as first argument negative numbers to select from the end of an array. If  the second argument is missing, all elements from the start position and to the end of the array will be selected and be part of the new array.

Examples

var String="Hello developers, welcome to CellScript!";

var n=String.slice(18,40);      
Net.write(n);                                // Returns welcome to CellScript!