This question already has an answer here:
- What is the usage of the backtick symbol (`) in JavaScript? 5 answers
I am to trying to learn Express library and Node.js one step at a time. First I am looking at is the specifics of the Node reqiure(moduleName)
function.
I took a look at the documentation for this, and found some weird code in the example documentation:
const circle = require('./circle.js');
console.log( `The area of a circle of radius 4 is ${circle.area(4)}`);
More specifically the ${circle.area(4)}
bit.
From what I understand the $
in JavaScript is just like any other variable. When we are using it on client side web development it is used as a delegate for the document function (I think). What is it assigned to when using node?
On top of that, what does this syntax mean? ${circle.area(4)}
If $
is just a reference to some function someFunction()
, wouldn't it be equivalent to this someFunction(){cirle.area(4)}
. I am not seeing how that could be valid syntax.
Also, why wouldn't they just directly call the circle.area()
function directly anyways?