frontend-challenges icon indicating copy to clipboard operation
frontend-challenges copied to clipboard

32 - InstanceOfClass - javascript

Open Ashish-j-shetty opened this issue 1 year ago • 0 comments

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)

}

Ashish-j-shetty avatar Nov 29 '24 12:11 Ashish-j-shetty