Page History
String variables in JavaScript have a number of very useful string functions. Here's a sample of the most commonly used:
Operation / Function | Example |
|---|---|
Concatenation | var S1 = "Customer"; |
IndexOf – finds first occurrence of a string in a string | /* 012345678901 */ |
lastIndexOf - finds last occurrence of a string in a string | /* 012345678901 */ |
charAt – returns the character at a specific position in a string | /* 012345678901 */ will put "H" into S2 and "A" into S3. |
length – returns the length of a string | /* 012345678901 */ |
substring – returns the substring of string using a starting and ending point. | /* 01234567789 */ |
substr – returns the substring of a string using a starting position and a length | /* 01234567789 */ will put "llo" into b. |
toLowerCase – returns the lowercase of string | var a = "Hello World"; will put "hello world" into b. |
toUpperCase – returns the uppercase of a string | var a = "Hello World"; |
|
There are more string functions like these available. See:
{+}http://www.w3schools.com/jsref/jsref_obj_string.asp+
for more details.