In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
What are the knowledge points of this article "what are the methods of concatenating strings in es6?" most people do not understand, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "what are the methods of concatenating strings in es6?"
Es6 concatenation string there are two ways to write: 1, in the template string using "${var}" to concatenate characters, written as "`${string 1} string 2`", "${}" can be put into the JS expression; 2, the use of the "+" operator, write "string 1 + string 2", the use of ternary expression, the need to use parentheses.
The operating environment of this tutorial: windows7 system, ECMAScript version 6, Dell G3 computer.
ES6 string concatenation
Strings can be concatenated in the following ways:
1. Use ${var} to concatenate characters in the template string
Const name = 'Xiaoming'; const score = 59 leading result =''; if (score > 60) {result = `$ {name} failed in the examination`;} else {result = `$ {name} failed in the examination`;} console.log (result)
Description:
ES6 has added ``(back quotation marks) to declare that the string wrapped in backquotes is a template string template string can be displayed on multiple lines and variable insertion can be run you can use any valid JavaScript expression such as `$ {2 * 3} `or `$ {foo ()}` in interpolation.
In es6, you can put JS expressions in ${}, perform operations, and reference object properties.
Mode 2 + operator concatenation characters
Note that when using ternary expressions, you need to enclose them in parentheses
Const name = 'Xiao Ming'; const score = 61'; if (score > 60) {result = name+' passed';} else {result = name+' passed';} console.log (result)
The above is about the content of this article on "what are the methods of concatenating strings in es6?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.