ChickenDreamFactory / fe-chicken

✨✨✨ 集锦 前端JavaScript 手写题,编程题,Not just for interviews

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

71.实现instanceof

webVueBlog opened this issue · comments

function myInstanceof (L, R) {
 if (L === null || typeof L !== 'object' || typeof R !== 'function') {
   return false;
 }
 let O = R.prototype;
 L = Object.getPrototypeOf(L);
 while(true) {
  if (!L) return false;
  if (O === L) return true;
  L = Object.getProperty(L);
 }
}