The use of "for ...in" loop with hasOwnProperty method

unnecessary code in the material?
the code i used is:


function Bird(name) {
this.name = name;
this.numLegs = 2;
}

let canary = new Bird("Tweety");
let ownProps = [];
// Only change code below this line
for (let property in canary) {
  ownProps.push(property)
}

the code used in the learning material:

for (let property in duck) {
  if(duck.hasOwnProperty(property)) {
    ownProps.push(property);
  }
}

why add the if statement?

**
**
Challenge: Understand Own Properties

Link to the challenge:

Just found the answer.
It’s there for the “prototype” thing :slight_smile: