📜  如何检查 javascript 变量的数据类型 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:16.847000             🧑  作者: Mango

代码示例1
let counter = 120; // counter is a number
console.log(typeof(counter)); // "number"

counter = false;   // counter is now a boolean
console.log(typeof(counter)); // "boolean"

counter = "Hi";   // counter is now a string
console.log(typeof(counter)); // "string"Code language: JavaScript (javascript)