Node.js uses the value usage ${}, but console.log () still outputs ${} directly and does not replace it with a variable value.

1. In node.js, the value usage ${} is in a string, but in console.log output, the console gets a string with ${} and does not replace the value of the variable.

app.use(async (ctx, next) => {
    const start = new Date().getTime();
    await next();
    let ms = new Date().getTime() - start;
    console.log("Time: ${ms}ms");
});

as shown in the code above, take out the value of the variable ms with ${} in console.log (), but in the final console output, you get the following result:

Time: ${ms} ms

May I ask what"s going on?

Jun.02,2021

if you want to use a template string, you can't use single or double quotes ( " '), instead use backquotes ( `). Tab the one above.
such as:

var time = `Time: ${+new Date()}`;
Menu