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 -
Replying to @padolsey
I'd you try 20[200]? The ECMAScript specification says that it should use %NumberPrototype% (ie, the original, builtin value of Number.prototype) rather than the current value of Number.prototype. So it should not be possible to substitute a Proxy into the 20[200] access
1 reply 0 retweets 1 like -
-
Allen, could you clarify what in particular is supposed to use %NumberPrototype% as opposed to (the modified) Number.prototype in this example?
1 reply 0 retweets 0 likes -
5.a.ii https://tc39.es/ecma262/#sec-getvalue … https://tc39.es/ecma262/#sec-properties-of-number-instances … "Number prototype object" Defined https://tc39.es/ecma262/#sec-properties-of-the-number-prototype-object … Admittedly not super obvious and ES6 editorial changes unintentionally made it less clear. ES5 spec clearer in this regard
2 replies 0 retweets 2 likes -
Isn’t it still %NumberPrototype% in the above example? The proxy in this example is not Number.prototype, it’s Number.prototype[[Prototype]] (which Get/Has/Set can hit).
2 replies 0 retweets 1 like -
yeah i think what's being missed in the discussion is that Number.prototype.__proto__ is being changed from Object.prototype to the proxy. That seems... legal.
1 reply 0 retweets 2 likes -
Allen Wirfs-Brock Retweeted Allen Wirfs-Brock
But see
@getify tweet up thread fromhttps://twitter.com/awbjs/status/1137398131606163456?s=09 …Allen Wirfs-Brock added,
1 reply 0 retweets 2 likes
Yeah, that’s what I thought too.
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.