While I am doing some revision to gain a better understanding of what I am dealing with. I have found myself asking the same question over and over again.
Now that everything is beginning to click, I found “methods” that appears to have the same function and I am having some trouble attempting to find their difference.
- From my understanding an (instanceof) method is simply asking whether the object is created from object.
- The same question appears to being asked by (isPrototypeOf) method.
Q1) What is the difference between those two methods?
Q2) In the code below, when (isPrototypeOf) is being used to check beagal, How come the word prototype is to be excluded?
Q2)(Possible answer) I suspect it’s because beagle is the final object to be created from the Chain of Objects.
**Your code so far**
function Dog(name) {
this.name = name;
}
let beagle = new Dog("Snoopy");
Dog.prototype.isPrototypeOf(beagle); // yields true
console.log(beagle instanceof Dog) //yields true
console.log(Dog.prototype.isPrototypeOf(beagle.prototype)); // yields false
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.87 Safari/537.36
Challenge: Understand the Prototype Chain
Link to the challenge: