https://github.com/imelgrat/es3-object-properties-iteration
ES3 Object properties iteration with the for..in loop
https://github.com/imelgrat/es3-object-properties-iteration
enumerable enumeration iteration javascript object-property objects objects-and-scenes
Last synced: about 1 month ago
JSON representation
ES3 Object properties iteration with the for..in loop
- Host: GitHub
- URL: https://github.com/imelgrat/es3-object-properties-iteration
- Owner: imelgrat
- Created: 2020-03-31T21:50:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-07T01:23:07.000Z (about 6 years ago)
- Last Synced: 2025-12-29T23:04:12.523Z (6 months ago)
- Topics: enumerable, enumeration, iteration, javascript, object-property, objects, objects-and-scenes
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ES3 Object properties iteration
Before ES6, the only way of iterating with an object's properties was the `for...in` loop. When you loop through an object with the `for...in` loop, you need to verify that the property belongs to the object (and is not inherited.).
One known limitation of the `for...in` loop is that it iterates through all properties in the Prototype chain. If you only want to show the object's properties, without the inherited ones, you need to verify that the property belongs to the object. The simplest way to do this is by using the **.hasOwnProperty()** method.
Read more at: https://imelgrat.me/javascript/object-properties-iteration-in-javascript/