手写instanceof原创
# 手写instanceof
// 沿着隐式原型链不断查找
function instanceOf(instance,prototype){
let i = instance;
while(i){
if(i.__proto__==prototype){
return true;
}
i = i.__proto__;
}
return false;
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12