📅  最后修改于: 2022-03-11 15:02:53.533000             🧑  作者: Mango
// check if a variable is of a certain type
var myVar = "This is a string";
if (typeof myVar === "string") {
console.log("It's a string!");
} else if (typeof myVar === "number") {
console.log("It's a number!");
};
// would return "It's a string!" in this case