Understand Own Properties - question

Hi, can someone please clarify why is the if(duck.hasOwnProperty(property)) necessary in the below example if we can just iterate over all properties with for (let property in duck) {ownProps.push(property)}?

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

let duck = new Bird("Donald");

let ownProps = [];

for (let property in duck) {
  if(duck.hasOwnProperty(property))  {

The answer to your question will come in a future lesson you have not reached just yet.

Hey @RandellDawson!

I’ve just passed this lesson and it all really sunk in. My only issue is I don’t understand how it actually checks the object for the property. Will it check for all properties or for those passed into (property), or is it just that it has been declared and it checks if the declared (let property) is an own property of duck?

Thanks in advance!

Did you get past the next two challenges?

Haha! Funny enough I did, and now understand the code!