javascript yield
function* foo(index) {
while (index < 2) {
yield index;
index++;
}
}
const iterator = foo(0);
console.log(iterator.next().value);
// expected output: 0
console.log(iterator.next().value);
// expected output: 1function* g1() {
yield 2;
yield 3;
yield 4;
}
function* g2() {
yield 1;
yield* g1();
yield 5;
}
const iterator = g2();
console.log(iterator.next()); // {value: 1, done: false}
console.log(iterator.next()); // {value: 2, done: false}
console.log(iterator.next()); // {value: 3, done: false}
console.log(iterator.next()); // {value: 4, done: false}
console.log(iterator.next()); // {value: 5, done: false}
console.log(iterator.next()); // {value: undefined, done: true}
Also in JavaScript:
- javascript open new window
- crucer in js
- dropdown option selection change event in jquery
- javascript document load
- jquery table row calculation
- in which table our redux option values are save
- variables 2 python .Bartolome sintes Marco
- js set visibility
- react player disable download
- libuv nodejs
- angular how to copy text with button
- discord.js clear code
- get current directory vbscript
- boble sorting javascript
- javascript write to file
- create callback function javascript
- how to update node modules
- react keep screen on
- nextjs "mssql" server
- .remove javascript
- how to floor a number in javascript
- how to count occurences in an array with javascript
- js check if attribute exists
- convert excel file to json using node js