Skip to main content

string.slice(startIndex, endIndex)

Creates a sub-string from a string

Availability

Device + Agent

Parameters

Name Type Description
startIndex Integer The string index of the sub-string’s first character
endIndex Integer Optional index of the character after the last character to be added to the sub-string

Returns

String — the specified sub-string

Description

This method copies a sequence of characters from the target string into a new string which it returns. The first parameter is the index of the first character to be copied from the source string. Squirrel continues copying characters one after the other from this point onward until it reaches either the end of the source string or the index specified as the method’s optional second parameter. The character with the same index as this optional value is not copied.

Example Code