This article mainly introduces the representation of JSES6 multi-line strings and connection strings, and compares and analyzes the representation and related operation skills of multi-line strings and connection strings in ES6 based on the specific instance form, if you need it, refer to the next article to introduce the representation of multiple lines of strings and connection strings in JS ES6, compare and analyze the multi-line strings in ES6 and the representation and related operation skills of the connected strings based on the specific instance form. For more information, see
This article describes how to express multiple-line strings and connection strings in JS ES6. We will share this with you for your reference. The details are as follows:
1. In the past, it was quite troublesome to Write multi-line strings in js with \ n. Therefore, the latest ES6 standard added a multi-line string representation method, represented:
Old Version
Alert ("Hello, \ n my name is \ n Olive ");
New Version
Alert ('hello, my name is olive'); // note that the two points here are the buttons on the left of the number key 1 on the keyboard, not single quotes.
2. In the past, multiple strings were connected and can be connected with a plus sign (+ ).
Var name = "olive"; var age = 26; var message = 'hello, my name is '+ name +', I \ 'M' + age + 'years old '; alert (message );
However, if there are many variables that need to be connected, it would be troublesome to use the plus sign. ES6 adds a string connection method:
Var name1 = "Mike"; var age1 = 20; var message1 = 'hello, $ {name1}, your age is $ {age1} '; // likewise, the two points here are the buttons on the left of the number key 1 on the keyboard, rather than the single quotation marks (alert (message1 );
The above is a detailed analysis of the representation and related operation skills of multiple strings and connection strings in ES6. For more information, see other related articles in the first PHP community!