Skip to content

Instantly share code, notes, and snippets.

@BolajiAyodeji
Created March 3, 2019 14:50
Show Gist options
  • Save BolajiAyodeji/cd12437019309df42c5365b5d0aef5ab to your computer and use it in GitHub Desktop.
Save BolajiAyodeji/cd12437019309df42c5365b5d0aef5ab to your computer and use it in GitHub Desktop.
Enumerating Properties of an Object
const circle = {
radius: 1,
draw() {
console.log('draw');
}
};
for (let key in circle) {
console.log(key, circle[key]);
}
for (let key of Object.keys(circle)) {
console.log(key, circle[key]);
}
for (let entry of Object.entries(circle)) {
console.log(entry);
}
if ('radius' in circle) {
console.log('Yes')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment