Hello campers, I have a question about checking the properties of an instance.
let ownProps = [];
let prototypeProps = [];
for (let property in duck) {
if(duck.hasOwnProperty(property)) {
ownProps.push(property);
} else {
prototypeProps.push(property);
}
}
console.log(ownProps);
console.log(prototypeProps);
Why do I have to check with the if statement if the duck has the property, even though I’m looping through the properties of duck?