String string object, String string object

Source: Internet
Author: User

String string object, String string object

The string object has been used in the previous study. The method for defining a string is to assign a value directly. For example:

Var mystr = "I love JavaScript! "

After defining the mystr string, we can access its attributes and methods.

Length:

StringObject. length; returns the length of the string.

Var mystr = "Hello World! "; Var myl = mystr. length;

After the above code is executed, the value of myl will be: 12

Method for accessing string objects:

Use the toUpperCase () method of the String object to convert lowercase letters of the String to uppercase:

Var mystr = "Hello world! "; Var mynum = mystr. toUpperCase ();
After the preceding code is executed, the value of mynum is hello world!

Use the toLowerCase () method of the String object to convert uppercase letters into lowercase letters.

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.