Array and string method differences

Source: Internet
Author: User

String

1 string immutable, if you assign a value to an index of a string, there will be no error, but no effect

Such as:

var s = ' Text ';

S[0] = ' X; '

alert (s); S is still ' Text '

2JavaScript provides some common methods for strings, note that the calling method itself does not alter the contents of the original string, but instead returns a new string.

2.1 toUpperCase The letters in the string into full capitalization

2.2 toLowerCase The letters in the string into full lowercase

2.3 IndexOf index Specifies where the string appears, such as var s = ' Text ' s.indexof (' e ')//1

2.4 substring returns the substring between the specified index area such as: var s = ' Text ' var a = s.substring (1,3)//ex, the first parameter must be positive, the second parameter does not have to, if not, then from the first parameter to the last, the value of opening and closing.

Array and string method differences

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.