What does this `…${…}…` code in the node docs mean? [duplicate]

This:

`The area of a circle of radius 4 is ${circle.area(4)}`

is an example of ES2015 template strings.

It interpolates whatever circle.area(4) represents directly into the string. If you’re curious about this or other ES2015 features, I recommend checking out Babel and playing around in the REPL.

Here’s a very simple example to get you started.

You can see this ES2015 code:

const foo = 'some text';
console.log(`${foo} is interpolated.`);

is transpiled to its ES5 equivalent – a simple + concatenation:

var foo = 'some text';
console.log(foo + ' is interpolated.');

Leave a Comment