The string object is used to process existing character blocks.
Javascript string object instance
- Calculate the length of a string
- How to Use the Length attribute to calculate the length of a string.
- Add a style to a string
- How to add a style to a string.
- Indexof () method
- How to Use indexof () to locate the first occurrence of a specified character in a string.
- Match () method
- How to Use match () to find a specific character in a string, and if so, return this character.
- Replace ()
- How to Use the Replace () method to replace some characters in a string.
Complete String object reference manual
Please refer to ourJavascript string object reference manualAll attributes and methods that can be used with string objects are provided.
This Manual contains detailed descriptions and examples of the usage of each attribute and method.
String object
The string object is used to process existing character blocks.
Example:
The following example uses the Length attribute of a string object to calculate the length of a string.
VaR TXT = "Hello world! "Document. Write (txt.Length
)
The aboveCodeOutput:
12
The following example uses the touppercase () method of the string object to convert the string to uppercase:
VaR TXT = "Hello world! "Document. Write (txt.Touppercase ()
)
The above code output is:
Hello world!