Created
November 2, 2019 14:11
-
-
Save AkashRajvanshi/d9c296f16a50e715ee4395d405f69bf6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const properties = Object.keys(user); | |
// length = len | |
let i, len; | |
for (i=0, len=properties.length; i<len; i++) { | |
console.log("Name: " + properties[i]); // Name: firstName, Name: showDetails | |
console.log("Value: " + user[properties[i]]); // Value: Akash, Value: function () | |
} | |
console.log(properties) // [ 'firstName', 'showDetails' ] | |
// Custom Property in user | |
console.log("firstName" in user); // true | |
console.log(user.propertyIsEnumerable("firstName")) // true (because it is listed in Object.keys()) | |
// Inherited Property | |
console.log("length" in properties); // true | |
console.log(properties.propertyIsEnumerable("length")) // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment