Please see the comments on the last two lines of code. What does constructor==Object do?
To check whether something is an object I found out that we use this:
typeof instance === “object”
So what exactly does constructor==Object do or what are we doing it instead of doing typeof instance === “object”?
**Your code so far**
function Dog(name) {
this.name = name;
}
// Only change code below this line
Dog.prototype = {
//constructor: Dog,
numLegs: 4,
eat: function() {
console.log("nom nom nom");
},
describe: function() {
console.log("My name is " + this.name);
}
};
let woof=new Dog();
console.log(woof.constructor===Object); //what does this do?
console.log(typeof woof==="object"); //isn't this how we check whether something is an object or not
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 OPR/76.0.4017.177
Challenge: Remember to Set the Constructor Property when Changing the Prototype
Link to the challenge:
