⊗jsPmBsTS 31 of 504 menu

Template strings in JavaScript

There is a special type of quotes - backticks:

let str = `abc`; alert(str); // shows 'abc'

With backticks you can perform insertion of variables. To do this, you need to write the variable name in the construction ${}.

Let's look at an example. Let's say we want to add strings and a variable:

let str = 'xxx'; let txt = 'aaa ' + str + ' bbb';

This code can be rewritten like this:

let str = 'xxx'; let txt = `aaa ${str} bbb`;

Rewrite the following code, using variable insertion:

let str1 = 'xxx'; let str2 = 'yyy'; let txt = 'aaa ' + str1 + ' bbb ' + str2 + ' ccc';
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline