Changes

JavaScript String Object

87 bytes added, 17:37, 4 June 2007
no edit summary
The JavaScript String Object is one of the most useful of the JavaScript Core Objects. It provides a range of methods thaty that can be used to perform a variety of string manipluation tasks (replacing parts of a string with different text, extreacting frgaments extracting fragments of a string, finding where a particular character appears in a string and much, much more).
== Creating a JavaScript String Object ==
</pre>
returns the postion index of the word ''my'' in the string (the word ''my'' begins at position 8 because the first character is always index position 0, '''not''' index position 1).
To split a string up based on the locations of a specified delimiter (in this case semi-colons):
<pre>
 
myString = new String ("This is my string");
 
var stringArray = myString.split(";");
</pre>
== Summary ==
In this chapter we have looked at one of the most powerful and frequently used javaScript JavaScript core objects - the String Object. As a JavaScript developer much of your time will be spent validating and manipulating string data entered by web site users. By combining the many methods of the String object it is possible to perform just about any string validation or manipulation tasks imaginable. As with any technology experimentation is the key to getting up to speed on JavaScript Strings so fire up your favorite editor and start trying out the methods described above.