js判断变量类型

var a = xxxxxxxx;
if(typeof a == "number") {
    //a是数
} else if(typeof a == "string") {
    //a是字符串
} else if(typeof a == "undefined") {
    //a是未定义
} else if(typeof a == "boolean") {
    //a是bool变量
} else if(typeof a == "object") {
    //a是对象
}
var b = new Date();
if(b instanceof Date) {
    //b是Date类型的
}
var c = [];
if(c instanceof Array) {
    //c是数组
}
原文地址:https://www.cnblogs.com/cailijuan/p/10168793.html