JS 模拟实现instaceof

==>

 1 function instanceOf(inst, clz) {
 2   const prototype = clz.prototype;
 3   let proto = inst.__proto__;
 4   while (proto !== null) {
 5     if (proto === prototype) return true;
 6     proto = proto.__proto__;    
 7   }  
 8 
 9   return false;  
10 }

 

posted @ 2022-02-20 15:19  樊顺  阅读(34)  评论(0编辑  收藏  举报