Skip to content

Instantly share code, notes, and snippets.

@whitershade
Created January 10, 2017 00:18
Show Gist options
  • Save whitershade/b8994197aaeb352b74f824ab31fd6c0a to your computer and use it in GitHub Desktop.
Save whitershade/b8994197aaeb352b74f824ab31fd6c0a to your computer and use it in GitHub Desktop.
let user = {
name: "sam", totalReplies: 17, isBlocked: false
};
user[Symbol.iterator] = function(){
let properties = Object.keys(this);
let count = 0;
let isDone = false;
let next = () => {
if(count >= properties.length){
isDone = true;
}
let value = this[properties[count++]];
return { done: isDone, value };
};
return { next };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment