//检测类型
var str = "Hello World";
if (typeof str=="string") {//使用typeof来判断对象类型的一个例子
}
if (str.constructor==String) {//使用构造函数属性来判断对象的类型
//constructor 属性在每个对象中都存在,并一直指向创建它的函数
}
相关文章: