判断一个对象是哪个类型:constructor
var test=new Array();
if(test.constructor==Array){
document.write("this is an Array")
}else if(test.constructor==Boolean){
document.write("this is a Boolean")
}else if(test.constructor==String){
document.write("this is a String")
}else if(test.constructor==Date){
document.write("this is a Date")
}
判断数据类型:typeof
typeof a