HELP! * GREY=local LOCAL HTML version of Foils prepared 15 January 1997

Foil 43 Explanation of String methods - II

From JavaScript Tutorial for CPS616 Technologies of the Information Age 1997 Basic Information Track of CPS -- Spring Semester 97. by Geoffrey C. Fox * Important Information in IMAGE
Secs 76.3
This example introduces two new methods
actualstring.IndexOf(lookfor); // where lookfor can be any string or property holding a string
This returns index in actualstring where character in actualstring starts a substring that exactly matches lookfor
"http://www.npac.syr.edu".IndexOf("www"); // returns 7
actualstring.IndexOf(lookfor, searchfrom); // searchfrom is the index where search starts -- in example where we scan for commas, searchfrom is set to be one more than location where last comma found
IndexOf and lastIndexOf return -1 if requested string cannot be found
actualstring.lastIndexOf(lookfor, lastsearchfrom); // is just like IndexOf but starts from the end not the beginning of the string
default value of lastsearchfrom is actualstring.length-1



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat May 24 1997