Try:
var g = f();
// this question is over this value.
g.next(); // returns: { value: 1, done: false }
g.next(123); // returns: { value: 2, done: false }
g.next(456); // returns: { value: [123, 456], done: true }
More Related Contents:
- Is there a mechanism to loop x times in ES6 (ECMAScript 6) without mutable variables?
- What can we do with ES6 Generator that we cannot with for loop?
- Is it possible to reset an ECMAScript 6 generator to its initial state?
- SyntaxError: Unexpected Identifier (Generators in ES6)
- What is Node.js? [closed]
- Do common JavaScript implementations use string interning?
- Javascript regex hangs (using v8)
- ECMAScript 6 features available in Node.js 0.12
- How can I clone a JavaScript object except for one key?
- garbage collection with node.js
- JavaScript double colon (bind operator)
- Executing JavaScript without a browser?
- Slowdown due to non-parallel awaiting of promises in async generators
- JavaScript ES6: Test for arrow function, built-in function, regular function?
- Why is let slower than var in a for loop in nodejs?
- Understanding code flow with yield/generators
- Function parameter definitions in ES6
- Running V8 Javascript Engine Standalone
- What’s the time complexity of array.splice() in Google Chrome?
- Are JavaScript Arrays actually implemented as arrays?
- check if function is a generator
- Object descriptor getter/setter performance in recent Chrome/V8 versions
- Using ‘let’ as a variable name is not throwing any errors in google v8
- stack and heap in V8 ( JavaScript)
- Access function location programmatically
- Why doesn’t Node.js have a native DOM?
- Maximum number of entries in Node.js Map?
- Lexer written in Javascript? [closed]
- Where argument of first next() call goes? [duplicate]
- Is google apps script synchronous?