crop_rotate
Run
<!DOCTYPE html> <html> <body> <h2>JavaScript Iterables</h2> <p id="demo"></p> <script> // Create an Object myNumbers = {}; // Make it Iterable myNumbers[Symbol.iterator] = function() { let n = 0; done = false; return { next() { n += 10; if (n == 100) {done = true} return {value:n, done:done}; } }; } let text = "" for (const num of myNumbers) { text += num +"<br>" } document.getElementById("demo").innerHTML = text; </script> </body> </html>
PCFET0NUWVBFIGh0bWw+DQo8aHRtbD4NCjxib2R5Pg0KPGgyPkphdmFTY3JpcHQgSXRlcmFibGVzPC9oMj4NCg0KPHAgaWQ9ImRlbW8iPjwvcD4NCg0KPHNjcmlwdD4NCi8vIENyZWF0ZSBhbiBPYmplY3QNCm15TnVtYmVycyA9IHt9Ow0KDQovLyBNYWtlIGl0IEl0ZXJhYmxlDQpteU51bWJlcnNbU3ltYm9sLml0ZXJhdG9yXSA9IGZ1bmN0aW9uKCkgew0KICBsZXQgbiA9IDA7DQogIGRvbmUgPSBmYWxzZTsNCiAgcmV0dXJuIHsNCiAgICBuZXh0KCkgew0KICAgICAgbiArPSAxMDsNCiAgICAgIGlmIChuID09IDEwMCkge2RvbmUgPSB0cnVlfQ0KICAgICAgcmV0dXJuIHt2YWx1ZTpuLCBkb25lOmRvbmV9Ow0KICAgIH0NCiAgfTsNCn0NCg0KbGV0IHRleHQgPSAiIg0KZm9yIChjb25zdCBudW0gb2YgbXlOdW1iZXJzKSB7DQogIHRleHQgKz0gbnVtICsiPGJyPiINCn0NCg0KZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImRlbW8iKS5pbm5lckhUTUwgPSB0ZXh0Ow0KPC9zY3JpcHQ+DQo8L2JvZHk+DQo8L2h0bWw+