Created
April 24, 2016 15:13
-
-
Save gurucharanmk/8115a930895f750834ef1372707e79d5 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
let iterable = { | |
0: 'a', | |
1: 'b', | |
2: 'c', | |
length: 3, | |
[Symbol.iterator]() { | |
var keys = Object.keys(this).sort(); | |
var index = 0; | |
return { | |
next: function () { | |
return { | |
value: keys[index], done: (index++ >= keys.length-1) | |
}; | |
} | |
} | |
} | |
}; | |
for (let item of iterable) { | |
console.log(item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment