[JavaScript Grammar Learning] Full introduction to String

Source: Internet
Author: User

A string is a sequence of Unicode characters. A string global object is a constructor used to construct a string object or a sequence of characters

Grammar

1. The literal syntax of a string, in the ES6 standard, is called the template literal. Refer to Typescript for details

2. String constructor string (thing)/new string (thing)

Escape character

\ \ \ \ \ \ \ \ \ \v \b \f \uxxxx

Long string

Two methods:

1. Concatenate multiple strings using the + operator

2. Use a backslash \ At the end of each line to indicate that the string will continue on the next line. Make sure that there are no spaces behind the backslash or any characters other than the newline character or indentation.

Methods and application scenarios for string objects

1. Get a single character from a string

CharAt

array index mode []

2. String comparisons

> < >= <=

Localecompare ()

3. The difference between a basic string and a String object

string literals and strings directly through the string method are basic strings, and JS automatically converts the base string to a String object. Only String objects can use the method of a String object.

String property

String.prototype.constructor

String.prototype.length

String method

static method: String.fromCharCode ()

Example method: String.prototype.charAt ()

String.prototype.charCodeAt ()

String.prototype.codePointAt ()

String.prototype.concat ()

String.prototype.indexOf ()

String.prototype.lastIndexOf ()

String.prototype.localeCompare ()

String.prototype.match ()

String.prototype.replace ()

String.prototype.search ()

String.prototype.split ()

String.prototype.substr ()

String.prototype.substring ()

String.prototype.toLocaleLowerCase ()

String.prototype.toLocaleUpperCase ()

String.prototype.toLowerCase ()

String.prototype.toString ()

String.prototype.toUpperCase ()

String.prototype.trim ()

String.prototype.valueOf ()

[JavaScript Grammar Learning] Full introduction to String

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.