Analysis of expression methods and related operation skills of multiple strings and connected strings in ES6

Source: Internet
Author: User
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!

Related Article

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.