Tell us what’s happening:
In the last few challenges, I have learned about the instanceof, constructor === and now, isPrototypeOf. They have seems the same to me: when a constructor function creates a new object, it inherits its prototype and also is an instance of its constructor. The console log below from my code all output to true. So what’s the difference in using those 3?
function Dog(name) {
this.name = name;
}
let beagle = new Dog("Snoopy");
// Only change code below this line
Dog.isPrototypeOf(beagle);
console.log(Dog.prototype.isPrototypeOf(beagle)); //true
console.log(beagle.constructor === Dog); //true
console.log(beagle instanceof Dog); //true
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
Challenge: Understand Where an Object’s Prototype Comes From
Link to the challenge: