On Fri, Oct 5, 2012 at 7:11 AM, Sam Tobin-Hochstadt <[email protected]> wrote:
> Note also that `Symbol.for` has some really weird behavior. For
> example, what does this evaluate to?
>
> Symbol.for("x") instanceof Symbol
>
> That depends if someone has previously evaluated `Symbol.for("x")` in
> a different frame.
This isn't weird at all. It's "true" regardless of whether
Symbol.for("x") has been evaluated elsewhere.
Symbol.for("x") creates a Symbol with forgeability (so that other
frames can successfully forge the Symbol and buy into your API). It
doesn't need to create identical objects, any more than String("x")
needs to create identical objects every time. So long as every
instance of Symbol.for("x") can be interchanged as a property name,
you're fine.
(In your assumed behavior, Symbol.for() would still be an unpluggable
cross-frame messaging hole, contrary to Mark Miller's goals. It would
be low bandwidth, of course (one bit per Symbol), but still.)
~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss