frontend-challenges
frontend-challenges copied to clipboard
32 - InstanceOfClass - javascript
index.js
export function instanceOfClass(obj, targetClass) {
if(typeof obj !== 'object' || obj==null){
return false
}
const instace = Object.getPrototypeOf(obj);
if( instace === targetClass.prototype){
return true;
}
return instanceOfClass( instace , targetClass)
}