Created
January 10, 2017 00:18
-
-
Save whitershade/b8994197aaeb352b74f824ab31fd6c0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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