function instance_of(L,R){ const baseType = ['string','number','boolean','undefined','null','symbol']; if(baseType.includes(typeof L)) { return false } let RP = R.prototype; let Lp = L.__proto__; while(true){ if(Lp === null){ return false; } if(Lp === RP){ return true; } Lp = Lp.__proto__; } } function person(name){ this.name = name; } var children = new person('小孩'); console.log(instance_of(children,person)); //true console.log(children instanceof person); //true