Syntax to get same object that method was called on (Easy methodchaining)

Adam Ahmed aahmed at
Mon Oct 26 10:02:09 UTC 2015

Hello, it's me, long-time lurker and person whose opinion shouldn't matter.

I find the syntax and semantics of this to be nothing I've ever had a use
case for, and I think it would make the language more complicated without
much benefit.

But if JS really wanted something like this, I'd prefer to bring back
with() in strict mode with some better syntax and semantics. No confusing
fallback to the outer scope, and hopefully syntax that avoids the question
of where a value comes from (e.g., requiring a leading dot or square

with(obj) {

    .boom(); // TypeError obj.boom is undefined

    .toString(); // no ASI needed, makes it "2"

    ["returnsTwo"]() // 2

    [] // invalid statement

    .a = 42;
obj.a // 42

But even then I'm not sure about this general idea. And don't see much
readability benefit in most cases.

Thanks for listening.

On Oct 26, 2015 7:59 PM, "Salvador de la Puente González" <
salva at> wrote:

If that exists I think it should be the context object the function is
called with. So `foo()#` is simply undefined in strict mode.
El 26/10/2015 7:48, "Edwin Reynoso" <eorroe at> escribió:

> That's not possible @Eric
> On Mon, Oct 26, 2015 at 2:20 AM, Eric Suen < at>
> wrote:
>> with
>>  obj.(doSomething(), doSomething2());
>> you don’t need to introduce new operator.
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at
> _______________________________________________
> es-discuss mailing list
> es-discuss at
es-discuss mailing list
es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list