Difference between revisions of "JavaScript String Object"
From Techotopia
(→Creating a JavaScript String Object) |
(→Creating a JavaScript String Object) |
||
Line 3: | Line 3: | ||
== Creating a JavaScript String Object == | == Creating a JavaScript String Object == | ||
− | An instance of a String object is created just as any other object instance is created (See [[JavaScript Object Basics]]). | + | An instance of a String object is created just as any other object instance is created (See [[JavaScript Object Basics]]). The object is created using the ''new'' keyword with the string to be used as the property passed through as the argument. For example: |
+ | |||
+ | <pre> | ||
+ | |||
+ | myString = new String("This is my string"); | ||
+ | |||
+ | </pre> |
Revision as of 19:12, 26 April 2007
The JavaScript String Object is one of the most useful of the JavaScript Core Objects. It provides a range of methods thaty can be used to perform a variety of string manipluation tasks (replacing parts of a string with different text, extreacting frgaments of a string, finding where a particular character appears in a string and much, much more).
Creating a JavaScript String Object
An instance of a String object is created just as any other object instance is created (See JavaScript Object Basics). The object is created using the new keyword with the string to be used as the property passed through as the argument. For example:
myString = new String("This is my string");