Improve answer for enumerating through JS object properties (#91)

I think it is necessary to mention the way to iterating over all non-enumerable properties
pull/92/merge
Nicholas Lee 7 years ago committed by Yangshun Tay
parent 9d74d2b836
commit 7247dbcaf7

@ -1240,6 +1240,7 @@ For objects:
- `for` loops - `for (var property in obj) { console.log(property); }`. However, this will also iterate through its inherited properties, and you will add an `obj.hasOwnProperty(property)` check before using it.
- `Object.keys()` - `Object.keys(obj).forEach(function (property) { ... })`. `Object.keys()` is a static method that will lists all enumerable properties of the object that you pass it.
- `Object.getOwnPropertyNames()` - `Object.getOwnPropertyNames(obj).forEach(function (property) { ... })`. `Object.getOwnPropertyNames()` is a static method that will lists all enumerable and non-enumerable properties of the object that you pass it.
For arrays:

Loading…
Cancel
Save