[JavaScript] JavaScript learns twenty-three javascript string (string) objects.

Source: Internet
Author: User

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!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.