The String object lets you work with a series of characters.
Syntax
Use the following syntax to create a String object −
var val = new String(string);
PROPERTIES:
1. CONSTRUCTOR- Returns a reference to the String function that created the object.
2. LENGTH- Returns the length of the string.
3. PROTOTYPE- The prototype property allows you to add properties and methods to an object.
METHODS:
1. charAt()-Returns the character at the specified index.
2. Concat()-Combines the text of two strings and returns a new string.
3. indexOf()-Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
4. lastIndexOf()-Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
5. replace()-Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
6. search()-Executes the search for a match between a regular expression and a specified string.
7. slice()-Extracts a section of a string and returns a new string.
8. substr()-Returns the characters in a string beginning at the specified location through the specified number of characters.
9. substring()-Returns the characters in a string between two indexes into the string.
10. toLowerCase()-Returns the calling string value converted to lower case.
11. toString()-Returns a string representing the specified object.
12. toUpperCase()-Returns the calling string value converted to uppercase.
13. valueOf()-Returns the primitive value of the specified object.
Syntax
Use the following syntax to create a String object −
var val = new String(string);
PROPERTIES:
1. CONSTRUCTOR- Returns a reference to the String function that created the object.
2. LENGTH- Returns the length of the string.
3. PROTOTYPE- The prototype property allows you to add properties and methods to an object.
METHODS:
1. charAt()-Returns the character at the specified index.
2. Concat()-Combines the text of two strings and returns a new string.
3. indexOf()-Returns the index within the calling String object of the first occurrence of the specified value, or -1 if not found.
4. lastIndexOf()-Returns the index within the calling String object of the last occurrence of the specified value, or -1 if not found.
5. replace()-Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring.
6. search()-Executes the search for a match between a regular expression and a specified string.
7. slice()-Extracts a section of a string and returns a new string.
8. substr()-Returns the characters in a string beginning at the specified location through the specified number of characters.
9. substring()-Returns the characters in a string between two indexes into the string.
10. toLowerCase()-Returns the calling string value converted to lower case.
11. toString()-Returns a string representing the specified object.
12. toUpperCase()-Returns the calling string value converted to uppercase.
13. valueOf()-Returns the primitive value of the specified object.
No comments:
Post a Comment