Benjamin Gruenbaum benjamingr at
Mon Oct 5 14:04:31 UTC 2015

Hey, other languages with default parameter values like Python, C#, Ruby
and PHP have a means to retrieve the default parameter values of a function.

>From what I understand (correct me if I'm wrong) - there is no way to get
the default values of a parameter of a function in JavaScript. For example:

function foo(x = 5){

Reflect.getDefaultParameterValues(foo); // {x : 5}

This would be very nice to have in the language in my opinion.

Now, doing this right sounds a bit challenging. since default parameters
get their value on every invocation of the function, it would have to
return getters (or functions) for values rather than values themselves.
There is also the issue of how `this` binding is handled by the said

Is there interest in such an API? Is there any previous work or discussions
about it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list