console.log(“test”);
}
Object.prototype.toString.call(fn); // “[object Function]”
自定义类型
function Person(name, age) {
this.name = name;
this.age = age;
}
var person = new Person(“Rose”, 18);
Object.prototype.toString.call(person); // “[object Object]”
很明显这种方法不能准确判断person是Person类的实例,而只能用instanceof 操作符来进行判断,如下所示:
console.log(person instanceof Person); // true