[PROPOSAL] "use" keyword

Tab Atkins Jr. jackalmage at gmail.com
Fri Jul 25 13:53:12 PDT 2014

On Fri, Jul 25, 2014 at 1:35 PM, Rick Waldron <waldron.rick at gmail.com> wrote:
> On Fri, Jul 25, 2014 at 4:29 PM, Tab Atkins Jr. <jackalmage at gmail.com>
> wrote:
>> Ah, so you've got a "private" variable (declared in a closure) that
>> you want to share with other objects which aren't created in the same
>> closure.
>> This is what Symbols/WeakMaps were made for.
> I'd be interested to see what your approach would be—afaict, this would
> require exposing the Symbol or WeakMap to whatever scope the foreign object
> is defined in and then there's no point in using either.

Yeah, upon actually walking through my desired example, I found that
the Symbol/Weakmap is irrelevant.  Here's what I was thinking, using
only existing stuff:

var shared1;

function ForeignObject() { /* Uses shared1 somehow */ }

ForeignObject.setSharedSecret(val) {
  shared1 = val;

var shared2 = "the real secret";

function MyObject() { /*...*/ }

MyObject.exposeSharedSecret(cb) {



More information about the es-discuss mailing list