标签:
<script>
function lol(type)
{
if(typeof type == "undefined")
{
alert("undefined");
}
else if(typeof type == "object")
{
if(new String(type) == "null")
{
alert(null);
}
else
{
if(typeof type.valueOf() == "string")
{
alert("引用类型 String")
}
else if(typeof type.valueOf() == "number")
{
alert("引用类型 Number");
}
else if(typeof type.valueOf() == "boolean")
{
alert("引用类型 Boolean");
}
else
{
alert("数组")
}
}
}
else if(typeof type == "function")
{
alert("function")
}
else
{
alert(typeof type)
}
}
var c ;
var d = null;
//lol(c);
//lol(d);
//lol(1)
//lol(new Number(1))
//lol("s")
//lol(new String(""));
//lol(true);
//lol(new Boolean(true))
//lol([])
</script>
js 区分undefined、null、基本数据类型、引用类型、函数、数组
标签:
原文地址:http://www.cnblogs.com/resolvent/p/5742763.html