Understand own properties explanation

Can someone please explain this example to me? Why is this FOR statement used in this way I don’t recall coming across it, what is the IN for and how is it used? Why do we need a property variable?

  **Your code so far**

let ownProps = [];

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

console.log(ownProps);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67

Challenge: Understand Own Properties

Link to the challenge:

Hi,

The in operator returns true if the specified property is in the specified object or its prototype chain.

Some docs to look at.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.