Skip to content

Instantly share code, notes, and snippets.

@leonardreidy
Last active September 30, 2019 08:14
Show Gist options
  • Save leonardreidy/d9ec6091a56ceb1f1c8a6bde83694e08 to your computer and use it in GitHub Desktop.
Save leonardreidy/d9ec6091a56ceb1f1c8a6bde83694e08 to your computer and use it in GitHub Desktop.
let ob = { age: 41, name: 'Leonard', profession: 'JavaScript Developer' };
let obit = iteratorFactory(ob);
obit.next(); // returns { value: { age: 41 }, done: false }
obit.next(); // returns { value: { name: 'Leonard'}, done: false }
obit.next(); // returns { value: { profession: 'JavaScript Developer'}, done: false }
obit.next(); // returns { value: undefined, done: true }
for(const o of obit){
console.log(o);
} // Throws
// Uncaught TypeError: obit is not iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment