Named Paramters

Alexander Kit alex.kit at
Tue Jul 14 11:03:32 UTC 2015

Seems everybody is pessimistic about this. But using optional `labels`
would solve any problem with the minifiers.
// Not minified (Labels are optional, default are the variable names)
function foo (bar = 1, baz = 2, bak = 3) {
foo (baz: 2);

// Minified
function foo(bar:a=1,baz:b=2,bak:c=3){console.log(b)}

// Explicit Label
function foo (bar = 1, baz: myVar = 2, bak = 3) {
foo (baz: 2);

// Minified (same)
function foo(bar:a=1,baz:b=2,bak:c=3){console.log(b)}

And when talking about static analysis, then it is really not always
possible to determine the global function variables, but within the
scope(s) it shouldn't be the problem. But anyway, the labels will cover all
the cases.

Sorry for bothering, if I miss something,

On 13 July 2015 at 14:54, Benjamin Gruenbaum <benjamingr at> wrote:

> If we _wanted_ to add named parameters, we would _probably_ have a
> _different_ name for the named parameter inside the function and outside
> the function.
> ```js
> function foo(x as y){
> }
> foo(y = 5);
> ```
> Or something like that. That said, I'm not convinced we _need_ named
> parameters, that they justify the additional cost or the overhead, that
> current solutions like destructing aren't enough and so on. Even if we all
> agreed that we want named parameters, and we agreed in general lines how it
> should be done, and we convinced the TC, there would still be a lot of work
> to actually "decide' they should make it to ES.
> So I suggest we close this thread and anyone who feel strongly about
> including named parameters should work on a concrete proposal :)
> Cheers,
> Benjamin
> On Mon, Jul 13, 2015 at 3:50 PM, Michał Wadas <michalwadas at>
> wrote:
>> In fact, it's impossible.
>> > And when the arguments are renamed during the minification, all
>> > the labels in function calls can be minified accordingly too.
>> You can't statically determine which function will be called. Minifier
>> CAN'T know in general case if your $(selector='wow') calls jQuery or
>> some other function at minify time.
>> So: you can't rely on optional parameters in any CDN-distributed file
>> (because your minifier doesn't know about it's pre-minification
>> identifiers), minifier have to avoid any parameters names clash at any
>> cost.
>> Possible solution: add gramar explicitly declare optional parameters
>> by keyword to avoid minifaction of their names names.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list