On 6 February 2015 at 10:19, Jordan Harband <[email protected]> wrote:
> Should a JS engine retain a reference to the original value of well-known > symbols (like Symbol.iterator), or should steps that use > well-known-Symbol-valued properties (like for..of iteration) always do a > dynamic lookup on that value? > The language never looks up any intrinsics dynamically. Given JavaScript's unreliable library semantics, that would break left and right. > http://jsfiddle.net/hzzo10dm/2/ is a proof of concept that demonstrates > in Chrome 40 that by replacing Symbol.iterator with another symbol, I can > create some weird behavior. > > What is specified to happen to built-in and custom iterables if I do > `Symbol.iterator = Symbol()`? > This is not having the effect you think it does: d8> var s = Symbol.iterator undefined d8> Symbol.iterator = Symbol("bla") Symbol(bla) d8> s === Symbol.iterator true It's just sloppy mode semantics not complaining. What you _can_ do, however, is: d8> Symbol = {iterator: Symbol("bla")} {iterator: Symbol(bla)} d8> s === Symbol.iterator false But that's just general JavaScript craziness. Fortunately, it still does not change the actual iterator symbol. /Andreas
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

