Cheap VPS host selection
Provide server host evaluation information

What are the tags used for javascript string constants

JavaScript string constants can be marked with single quotation marks (') or double quotation marks ("). These two marking methods are syntactically equivalent, and you can choose one according to your personal preference.

For example:

 let str1 = 'Hello World' ; let str2 = "Hello World" ;

Note that if you need to include the same quotation mark as the string mark in the string, you can use the escape character () to escape.

For example:

 let str3 = 'He said, "I\'m fine."' ; let str4 = "She said, \"Hello.\ "" ;

In addition, in ES6, template strings are also introduced as a new string expression, using backquotes( )Tag. The template string supports inserting variables and multiple lines of text, and can be ${} ` to insert an expression or variable.

For example:

 let name = 'Alice' ; let greeting = `Hello ${name} !` ; console . log (greeting); //Output: Hello Alice!

The template string provides a more flexible and convenient string splicing method, and is more intuitive and readable when dealing with complex strings.

Do not reprint without permission: Cheap VPS evaluation » What are the tags used for javascript string constants