JS - String Objects
JS - String Objects
Syntax
Use the following syntax to create a String object −
var val = new String(string);
The String parameter is a series of characters that has been properly encoded.
String Properties
Here is a list of the properties of String object and their description.
1 constructor
2 length
3 prototype
In the following sections, we will have a few examples to demonstrate the usage of
String properties.
String Methods
Here is a list of the methods available in String object along with their description.
1 charAt()
Returns the character at the specified index.
2 charCodeAt()
3 concat()
4 indexOf()
Returns the index within the calling String object of the first occurrence
of the specified value, or -1 if not found.
5 lastIndexOf()
Returns the index within the calling String object of the last occurrence
of the specified value, or -1 if not found.
6 localeCompare()
7 match()
8 replace()
9 search()
10 slice()
Splits a String object into an array of strings by separating the string into
substrings.
12 substr()
13 substring()
Returns the characters in a string between two indexes into the string.
14 toLocaleLowerCase()
15 toLocaleUpperCase()
16 toLowerCase()
17 toString()
18 toUpperCase()
19 valueOf()
1 anchor()
2 big()
3 blink()
4 bold()
5 fixed()
6 fontcolor()
7 fontsize()
8 italics()
9 link()
11 strike()
12 sub()
13 sup()