AlgoDaily Solution
1function instanceOfClass(obj, targetClass) {
2 if (!obj || typeof obj !== 'object') return false
3 if (!target.prototype) throw Error
4
5 if (Object.getPrototypeOf(obj) === target.prototype) {
6 return true
7 } else {
8 return instanceOfClass(Object.getPrototypeOf(obj), target)
9 }
10}
Community Solutions
Community solutions are only available for premium users.
Access all course materials today
The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.
xxxxxxxxxx
11
function instanceOfClass(obj, targetClass) {
if (!obj || typeof obj !== 'object') return false
if (!target.prototype) throw Error
if (Object.getPrototypeOf(obj) === target.prototype) {
return true
} else {
return instanceOfClass(Object.getPrototypeOf(obj), target)
}
}
OUTPUT
Results will appear here.