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 startPositionIndex parameter

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.