首页 > 解决方案 > 当我使用模板文字并运行代码时,结果未定义

问题描述

如果我写:

let x = 10;
let y = 20;

console.log(`Okay this is the answer: ${x+y}`);

我得到的结果是:

Okay this is the answer: 30
=> undefined

let x = 10;
let y = 20;

console.log(`Okay this is the answer: ${x+y}`);

我不明白这=> undefined在控制台中显示的结果中意味着什么。

注意:虽然上面给出的代码片段没有显示=> undefined,但如果我们在浏览器的控制台或repl.it中运行代码,它就会显示出来。

标签: javascript

解决方案


推荐阅读