Explanation on $ and ``?


In the looping through objects lesson, we console log a combination of text and variables using `` instead of ‘’. We also use the $ symbol to access our variables while we’re in there. I can’t find a lesson on either of those symbols in the Javascript documentation or this course. Can someone link me to a place where I can learn more about them?



What you refer to is a template literal which is a string intepolation tool.

Template literals are strings, but they are delimited with backticks, instead of ordinary quotes.

template = `This is still a string.`

In vanilla JS we would join strings using concatenation

stringA + stringB

With a template literal we can interpolate the variables in a template expression.

stringA = "This";
stringB = "string";
template = `${stringA} is still a ${stringB}.`


That clears up a lot. Thank you.


Are Template Literals covered in this course anywhere?


I’m not sure if or where they are brought up. Not much to know beyond the example above. It should be noted that a template expression can contain another template literal. It is also perfectly valid to the use backticks on plain strings.

Template literals