34,333
edits
Changes
→JavaScript String Object Examples
== JavaScript String Object Examples ==
Now that we are familiar with the methods and properties provided with the String object it is time to look at some examples. Before beginning , however, it is important to understand that the String Object methods do not modify the string contained in the object itself. Rather, a modified string is returned, leaving the original String object untouched.
After the following script fragment fragment is executed:
<pre>
myString = new String ("This is my string");
var upperCase = myString.toUpperCase(); // upperCase variable now contains ''THIS IS MY STRING''
myString = new String ("This Is My String");
var lowerCase = myString.toLowerCase(); // lowerCase variable now contains ''this is my string''
</pre>