- inStanceof ()
判断 对象 是否属于 构造函数这个类
// 构造函数Student
function Student() {
this.name = "王一";
}
// 构造函数Animal
function Animal() {
this.name = "汤姆";
}
// 对象s1
var s1 = new Student();
console.log(s1 instanceof Student); //true 判断s1是否属于Student类
console.log(s1 instanceof Animal); //false 判断s1是否属于Animal类
- isPrototypeOf() 在原型上判断
判断当前这个 对象 是否基于 对应原型 创建出来
// 构造函数Student
function Student() {
this.name =