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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access