About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Error processing SSI file

Substrings

Question: How do I extract a substring from a string?

Answer: To extract a substring from a string, use the substring method:

string.substring(start,end)
Here
string is the string from which you want to extract a substring.
start is the number specifying the position of the character at which the substring begins. (The character at start itself will be included in the substring.)
end is the number specifying the position of the character at which the substring ends. (The character at end will not be included in the substring.)

Note that the first character in the string corresponds to position 0, and the last character to position string.length-1.

Examples:

'Hello'.substring(0,2)  // 'He'
'Hello'.substring(0,4)  // 'Hell'

BackBack