The `` signs are used to create templates, they have the fitting name "template literals". These are used to make it more simple to create strings. Where you create a template and fill in the variables that should be replaced. Instead of having to concatenate them yourself.
Template literals
Often you would see something like the following when building strings:
let name = 'Peter';
let lastname = 'Rasmussen';
let textString = 'My name is: ' + name + ' ' + lastname;
Here we are concatenating several strings into the variable textString
. Had this been a longer string with several more variables the code could become hard to follow. Instead you can use template literals like below:
let name = 'Peter';
let lastname = 'Rasmussen';
let textString = `My name is: ${name} ${lastname}`;
To me this is a lot simpler and you avoid a lot of extra quotation marks. You can use all sorts of variables, not just the ones containing text. You can also do calculations within a template literal using ${2 + 3}
.
You may know template literals as $"My name is: {name} {lastname}"
in C# or "My name is: ${name} ${lastname}"
in Java. In these languages this feature is called string interpolation.
I hope this helped you to understand what these odd `` symbols mean. Please let me know if you liked this short post below in the comments. If you would like a more thorough post on this, I would advise you to check out this template literals page from Mozilla.