Name
substr() — NN 4 IE J3 ECMA n/a
Synopsis
substr(startPositionIndex[, length])
Returns a copy of an extract from the current string. The extract
begins at the zero-based index position of the current string as
specified by the first parameter of the method. If no other parameter
is provided, the extract continues to the end of the main string. The
second parameter can specify an integer of the number of characters
to be extracted from the main string. In contrast, the
substring() method’s parameters point to the
start and end position index values of the main string.
Returned Value
A string.
Parameters
-
startPositionIndex A zero-based integer indicating the position within the current string object to start copying characters
-
length An optional integer of the number of characters to extract, starting with the character indicated by the
startPositionIndexparameter
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