检查类型使用 typeof
填空题 入门
题目
Fill in 空白到 检查如果 `值` 是的 类型数字.
代码
const value = 42;
if (___ value === "number") {
console.log("It's a number!");
}
提示
Use 运算符那个返回类型 as 字符串.
解释
typeof 是运算符那个返回类型的 值 as 字符串. typeof 42 返回 "数字", so the comparison typeof 值 === "数字" 是真 and 消息是 printed.
相关资源
相关课程
- JavaScript 数据类型
学习关于 typeof.
查阅不认识的术语
新手友好的术语表用大白话解释编程术语——变量、函数、DOM、Promise 等等。
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。
动手做项目
通过引导式项目应用所学,含起始代码与解决方案。