【发布时间】:2011-02-16 01:46:14
【问题描述】:
显然,instanceof 和 typeof 都不能正确识别每个 javascript 对象的类型。我想出了这个功能,我正在寻找一些反馈:
function getType() {
var input = arguments[0] ;
var types = ["String","Array","Object","Function","HTML"] ; //!! of the top of my head
for(var n=0; n < types.length; n++) {
if( input.constructor.toString().indexOf( types[n] ) != -1) {
document.write( types[n] ) ;
}
}
}
感谢阅读!
【问题讨论】:
标签: javascript object types