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:
As you can see, the most important part to accessing string properties and functions is to first create them. In this case, myString was our guinea pig.
It is important to note that these functions do not actually change the string itself. Rather, they return new strings that you can store for use elsewhere. In our example, we stored the result of our make-believe function into myFunctionResult.
Pseudo JavaScript 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>
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 for finding out more about your string. For example, the string function split lets you take a string and chop it into pieces whenever characters that you supply, appear.It is important to note that these functions do not actually change the string itself. Rather, they return new strings that you can store for use elsewhere. In our example, we stored the result of our make-believe function into myFunctionResult.
0 comments
একটি মন্তব্য পোস্ট করুন