If判断接受的数据类型

If判断接受的数据类型If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型
If判断接受的数据类型

//判断是否为字符串类型
var str='3';
if(typeof(str)=='string'){
    console.log("是");
}else{
    console.log("xxxxx")
}
//判断是否数字
var a=3;
if(typeof(a)=='number'){
    console.log("是x");
}else{
    console.log("xxxxx")
}
//判断是否为数字
var a=3;
if(isNaN(a)==0){
    console.log("是x");
}else{
    console.log("xxxxx")
}
//空未定义均可采用判断字符串的方式进行if判断

typeof'';// string 有效
typeof1;// number 有效
typeofSymbol();// symbol 有效
typeoftrue;//boolean 有效
typeofundefined;//undefined 有效
typeofnull;//object 无效
typeof[] ;//object 无效
typeofnewFunction();// function 有效
typeofnewDate();//object 无效
typeofnewRegExp();//object 无效

typeof