Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: hasOwnProperty() for Object Property Iteration | Advanced Object Manipulation
course content

Зміст курсу

JavaScript Data Structures

Challenge: hasOwnProperty() for Object Property IterationChallenge: hasOwnProperty() for Object Property Iteration

Task

Create a loop that iterates through the properties of an object and prints each property along with its value. However, you should only print properties that belong directly to the object, not those inherited from its prototype chain. Utilize the hasOwnProperty() method to achieve this.

Expected output:

  1. Use a for...in loop to iterate through the object's properties.
  2. Within the loop, check if each property is an own property of the object using hasOwnProperty() before logging it.

Все було зрозуміло?

Секція 3. Розділ 4
course content

Зміст курсу

JavaScript Data Structures

Challenge: hasOwnProperty() for Object Property IterationChallenge: hasOwnProperty() for Object Property Iteration

Task

Create a loop that iterates through the properties of an object and prints each property along with its value. However, you should only print properties that belong directly to the object, not those inherited from its prototype chain. Utilize the hasOwnProperty() method to achieve this.

Expected output:

  1. Use a for...in loop to iterate through the object's properties.
  2. Within the loop, check if each property is an own property of the object using hasOwnProperty() before logging it.

Все було зрозуміло?

Секція 3. Розділ 4
some-alt