Skip to content

Instantly share code, notes, and snippets.

@behnamazimi
Last active January 15, 2020 07:27
Show Gist options
  • Save behnamazimi/0da04e8c45f7938e260718e5957caa2b to your computer and use it in GitHub Desktop.
Save behnamazimi/0da04e8c45f7938e260718e5957caa2b to your computer and use it in GitHub Desktop.
let user = { username: "bhnmzm", first_name: 'Behnam', last_name: "Azimi", title: "Front-End Developer" };
user[Symbol.iterator] = function*() {
for (let key in this) {
yield [key, this[key]];
}
};
for (let [key, value] of user) {
console.log(key + ": ", value)
}
//o: username: bhnmzm
//o: first_name: Behnam
//o: last_name: Azimi
//o: title: Front-End Developer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment