Predict Template Literal 输出
预测输出 中等
题目
什么做 这个 code print?
代码
type Greeting = `Hello ${string}`;
const msg: Greeting = `Hello World`;
console.log(msg);
提示
Template literal 类型是 编译-时间仅 — 值是 normal 字符串 at 运行时.
解释
template literal 类型 Hello ${字符串} matches 任何字符串开始使用 "Hello ". 值 msg 是 "Hello World". At 运行时, template literal 类型是 erased. 输出: Hello 世界.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。