87,910
社区成员
发帖
与我相关
我的任务
分享
function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype = {
showName : function(){
return this.name;
}
}
Person.prototype.constructor = Person;
var p = new Person();
function getType( obj ) {
var fName = obj.constructor.toString();
fName = fName.match(/function[\s*]?(.*)\(.*\)/);
if(fName[1]){
return '[object '+fName[1]+']'
}
}
alert(getType(p));