| Availability: |
| |||||||
| Property/method value type: | String primitive | |||||||
| JavaScript syntax: | - | myString.substr(aStartPosition) | ||||||
| - | myString.substr(aStartPosition, aLength) | |||||||
| Argument list: | aStartPosition | The index of the first character in the substring | ||||||
| aLength | The length of the substring | |||||||
This is a variation of the String.substring() method. The difference is that the substring length is passed as the second argument rather than the substring ending character index.
<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT>
myString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
myIndex = myString.indexOf("MN");
document.write(myString.substr(myIndex, 5));
</SCRIPT>
</BODY>
</HTML>| See also: | String.slice(), String.split(), String.substring() |
| Prev | Home | Next |
| String.sub() | Up | String.substring() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. | ||