Ok I now love iterators and generators. http://Number.prototype.to = function*(n) { for (let i = +this; i <= n; i++) yield i; } for (let i of 0..to(100)) {...}
-
Show this thread
-
Ok this is horrific but possible: // Loop from 20 to 200 for (let n of 20[200]) {} Pretty sure using a proxy on a native prototype is punishable by death. Please forgive me.https://gist.github.com/padolsey/4c948712e469d7492a346730ebe4ee2b …
3 replies 5 retweets 28 likesShow this thread -
Also WTF you can proxy native prototypes !??!? / Evil Genius Laugh
2 replies 0 retweets 11 likesShow this thread -
Less evil but still awful (?) is implementing a native iterator for number so that you can do things like: [...5]; // => [0, 1, 2, 3, 4] Here you go: Number.prototype[Symbol.iterator] = function*() { for (let i = 0; i < this; i++) yield i; };
2 replies 3 retweets 29 likesShow this thread -
With Number#to you can also do [...0..to(100)] which ain't bad.
4 replies 2 retweets 10 likesShow this thread
Mathias Bynens Retweeted Benedikt Meurer
We were chatting about this today and came up with something worse:https://twitter.com/bmeurer/status/1138760699805601792 …
Mathias Bynens added,
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.
Echoing a fun 