Name

slice() — NN 4 IE J3 ECMA n/a

Synopsis

slice(startPositionIndex, endPositionIndex])

Returns a substring of the current string. The substring is copied from the main string starting at the zero-based index count value of the character in the main string. If no second parameter is provided, the substring extends to the end of the main string. The optional second parameter can be another zero-based index value of where the substring should end. This value may also be a negative value, which counts from the end of the string toward the front.

Returned Value

String.

Parameters

startPositionIndex

A zero-based integer indicating the position within the current string object to start copying characters.

endPositionIndex

A zero-based integer indicating the position within the current string object to end copying characters. Negative values count inward from the end of the string.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.