js instanceof运算符

a instanceof B;

instanceof检测对象a的原型链中有没有构造函数B.prototype

如下:

function In (a, B) {

  var p = a.__proto__;

  if (p != null ) {

    if(p == B.prototype) {

      return true;

    }

    p = p.__proto__;

  }

  return false;

}

原文地址:https://www.cnblogs.com/a-flydog/p/5649192.html