Proposal: Property Accessor Function Shorthand

Isiah Meadows contact at
Tue Dec 3 11:33:13 UTC 2019

BTW, all this is very much just a special case of this (existing stage
1) proposal, and is part of why it exists:

I do find it surprising that property access isn't addressed there,
but it seems like it was likely just overlooked - it has no mention in
the repo, in the open issues, or even in the closed issues or any of
the open or closed pull requests.


Isiah Meadows
contact at

On Tue, Dec 3, 2019 at 5:43 AM Michael Luder-Rosefield
<rosyatrandom at> wrote:
> At the cost of adding more code, but giving more power, perhaps what we want is something akin to Kotlin's `it` keyword:
> it: implicit name of a single parameter
> It's very common that a lambda expression has only one parameter.
> If the compiler can figure the signature out itself, it is allowed not to declare the only parameter and omit ->. The parameter will be implicitly declared under the name it:
> ints.filter { it > 0 } // this literal is of type '(it: Int) -> Boolean'
> What we'd want is something concise and non-ambiguous to fulfill the same role; something that cannot currently be a valid identifier, maybe. This is the point where I start scanning the keyboard for underutilised symbols... I'm thinking the hash symbol would work. To re-use the original example:
> ```js
> const activeProducts = products.filter(;
> const productNames =;
> const sortedProducts = _.sortBy(products,;
> const { true: activeProducts, false: inactiveProducts } = _.groupBy(products,;
> ```
> It makes intuitive sense in 2 ways, I think; # makes you think of the object hash you're extracting a property from, and also is familiar as something's id from CSS selectors.
> We could also extend it to represent multiple parameters: # is also aliased as #0, the 2nd parameter is #1, etc.
> Further, dynamic properties would work too: `const fooProducts = products.filter(#[foo]);
> --------------------------
> Dammit babies, you've got to be kind.
> On Mon, 2 Dec 2019 at 22:32, Waldemar Horwat <waldemar at> wrote:
>> On 11/24/19 9:17 PM, Bob Myers wrote:
>> > FWIW, the syntax `.propName` does appear to be syntactically unambiguous.
>> It conflicts with contextual keywords such as `new . target`.
>>      Waldemar
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list