js 判断数据类型、检测变量类型、对象的类型(typeof)

我来纠错
//typeof,返回变量类型
typeof(1);  //返回:"number"
typeof(NaN);  //返回:"number"
typeof(Number.MIN_VALUE);  //返回:"number"
typeof(Infinity);  //返回:"number"
typeof("123");  //返回:"string"
typeof(true);  //返回:"boolean"
typeof([1,2,3]);  //返回:"object"
typeof([]);  //返回:"object"
typeof({"a":1,"b":2});  //返回:"object"
typeof(window);  //返回:"object"
typeof(document);  //返回:"object"
typeof(null);  //返回:"object"
typeof(eval);  //返回:"function"
typeof(Date);  //返回:"function"
typeof(sss);  //返回:"undefined"
typeof(undefined);  //返回:"undefined"

//实例
var test = function(){ var a=1; };
if(typeof test == 'function'){
	alert('这是一个function类型');
}
发送
热门关键词:
命令
知识类型:
标题描述:
详细解答:

提交审核您编辑的知识会经过 前端大牛 人工审核。