简体   繁体   中英

Curly brackets in jQuery

I found the following line in a tutorial on jQuery:

$tbody.append(`<tr>${abc+ def}</tr>`);

What does the curly brackets do in that case?
So, what's the purpose of this part:

${abc + def}

This feature is not related to jQuery and is called template literal . It is a new feature, appeared in ES6 . It will evaluate the ${abc + def} and put the value in the string.

This in ES6

`<tr>${abc+ def}</tr>` 

is equivalent to this in ES5

"<tr>" + (abc + def) + "</tr>"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM