Hello, I’m wondering why there is an if statement like this
let ownProps = [];
for (let property in duck) {
if(duck.hasOwnProperty(property)) {
ownProps.push(property);
}
}
console.log(ownProps); // prints [ "name", "numLegs" ]
when it could be done like this
let ownProps = [];
for (let property in duck) {
ownProps.push(property);
}
console.log(ownProps); // prints [ "name", "numLegs" ]
Why should it be checked if duck has a property, when it is 100% sure that it has?