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