constructor 属性
constructor 属性返回所有 JavaScript 变量的构造函数。
function isWhat(obj,type) { return obj.constructor.toString().indexOf(type)>-1; } var i=["a","b","c"]; console.log(isWhat(i,"Array"));
运行结果为:true
constructor 属性返回所有 JavaScript 变量的构造函数。
function isWhat(obj,type) { return obj.constructor.toString().indexOf(type)>-1; } var i=["a","b","c"]; console.log(isWhat(i,"Array"));
运行结果为:true