Javascript String Functions
This may be old news to you, but inside every Javascript string are several
functions that are just waiting to do your bidding. This is because strings in Javascript
are actually objects with a bunch of properties and functions (also called methods) that
can be accessed in the following general way:
Pseudo Javscript Code:
<script type="text/javascript">
var myString = "Hello Thur!";
//This is how you would access a property
var myProperty = myString.property;
//This is how you would access a function
var myFunctionResult = myString.function(argument1, argument2);
</script>
As you can see, the most important part about accessing a strings properties and functions is to
first create one, in this case myString was our guinea pig.
What's a String Property?
A property is just some basic information about the object. For example, a string object has a length property which
stores the number of characters in the string.
What's a String Function
The string's functions are useful ways to find out more about your string. For example, the string function
split lets you take a string and chop it into pieces whenever it sees the character(s) that you supply.
It is important to note that these functions
do not actually change the string itself, rather it returns a new string that you will have to store if you want to use it elsewhere.
As in our example, we stored the result of our make believe function into myFunctionResult.
String Functions and Properties
The following lessons will teach you how to manipulate, count, reorder, replace, search and do just about anything else
to your Javascript strings. These advanced topics will open up a whole new world of choices for the dynamic web pages you
have yet to build!
|