-
-
Save nathanhannig/b4276956a2f56901947b31aa23d1ffa2 to your computer and use it in GitHub Desktop.
Revisions
-
breakpoint25 created this gist
Aug 22, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ const james = { name: 'James', height: `5'10"`, weight: 185, [Symbol.iterator]: function() { const object = this; const keys = Object.keys(object); let index = 0; return { next: () => { const key = keys[index]; index++; return { value: object[key], key: key, done: !(index < keys.length) }; } }; } }; let iterator = james[Symbol.iterator](); console.log(iterator.next().value); // 'James' console.log(iterator.next().value); // `5'10` console.log(iterator.next().value); // 185