improve the answer

I think it is necessary to mention the way to iterating over all non-enumerable properties
pull/91/head
Nicholas Lee 8 years ago committed by GitHub
parent 9d74d2b836
commit 36559aa463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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. - `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.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: For arrays:

Loading…
Cancel
Save