Skip to content

Instantly share code, notes, and snippets.

@gurucharanmk
Created April 24, 2016 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gurucharanmk/8115a930895f750834ef1372707e79d5 to your computer and use it in GitHub Desktop.
Save gurucharanmk/8115a930895f750834ef1372707e79d5 to your computer and use it in GitHub Desktop.
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