String object
String objects are used to process text (strings).
String object creation method: new String().
Grammar
Or simpler way:
var txt = " string ";For the String Objects tutorial, check out the JavaScript String Objects tutorial.
String object properties
Attributes | describe |
---|---|
constructor | Quote for functions that create this object |
length | String length |
prototype | Allows you to add properties and methods to objects |
String object method
method | describe |
---|---|
charAt() | Returns the characters in the specified location. |
charCodeAt() | Returns a Unicode encoding of characters in the specified location. |
concat() | Connect two or more strings and return to a new string. |
fromCharCode() | Transfer Unicode encoding to characters. |
indexOf() | Returns a specified string value in the first place in the string. |
lastIndexOf() | Search the string from the back. |
match() | Find a match of one or more regular expressions. |
replace() | Find the matching substrings in the string and replace the substrings that match the regular expression. |
search() | Find the value that matches the regular expression. |
slice() | Extract the fragment of the string and return to the extracted portion in the new string. |
split() | Split the string into a string array. |
substr() | Extract the specified number of characters in the string from the starting index number. |
substring() | Extract characters between two specified index numbers in the string. |
toLowerCase() | Convert strings to lowercase. |
toUpperCase() | Convert the string to uppercase. |
trim() | Remove the blank on both sides of the string |
valueOf() | Returns the original value of a string object. |
String HTML wrapping method
The HTML wrapper method returns a string with the appropriate HTML tag added.
method | describe |
---|---|
anchor() | Create an HTML anchor. |
big() | Use a large font to display a string. |
blink() | Show a flashing string. |
bold() | Use a bold display string. |
fixed() | Display strings with typewriter text. |
fontcolor() | Use the specified colors to display the string. |
fontsize() | Use the specified size to display the string. |
italics() | Use a slope to display a string. |
link() | Display strings as a link. |
small() | Use a small number to display a string. |
strike() | A string for displaying the deletion of deletion. |
sub() | The string is displayed as the subscript. |
sup() | The string is displayed as a lacquered mark. |