Availability: |
| |||||||
Property/method value type: | String primitive | |||||||
JavaScript syntax: | - | myString.slice(startPos) | ||||||
- | myString.slice(startPos, endPos) | |||||||
Argument list: | endPos | The ending character position | ||||||
startPos | The starting character position |
The sub-string is identified using the parameters passed as arguments in the method call.
The second argument is optional. If it is missing then it is assumed to mean the end of the string.
<HTML> <HEAD> </HEAD> <BODY> <SCRIPT> myString = "AAABBBCCCAAABBBCCC"; myIndex = myString.lastIndexOf("AAA"); document.write(myString.slice(myIndex, myIndex+4)); </SCRIPT> </BODY> </HTML>
See also: | String.split(), String.substr(), String.substring() |
Prev | Home | Next |
String.search() | Up | String.small() |
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. |