JavaScript has an Object type String that can be used to perform various types of string functions such as substring, upper case, lower case, font styles, index of characters etc.
JavaScript String Function Examples
First of all to start with String Object Functions. See the following javascript code to create a variable of String type:
var myString = new String(); myString = "JavaScript String Function";
myString variable is assigned a string to perform the string functions:
String Anchor Function
Anchor function creates the HTML anchor.
Syntax
stringObject.anchor([name]);
Example
document.write( myString.anchor("topAnchor") );
String Big Function
Displays the string in Big font style.
Example
document.write( myString.big() );
String Blink Function
Blinks the displayed string. It does not work in Internet explorer.
Example
document.write( myString.blink() );
String Bold Function
Displays the bold fonts in string.
Example
document.write( myString.bold() );
String charAt Function
Displays the character at specified position of string.
Syntax
stringObject.charAt(index);
Example
document.write( myString.charAt(11) );
Output
S
String charCodeAt Function
Displays the Unicode of the character at the specified position of string.
Syntax
stringObject.charCodeAt(index);
Example
document.write( myString.charCodeAt(11) );
Output
83
Continue to next tutorial: JavaScript String Object Functions-2 to learn some more string functions.