I'm thinking of the same questions. I have yet to think of any use cases
for this.

On Mon, Oct 5, 2015, 10:32 Thomas <thomasjamesfos...@bigpond.com> wrote:

> My initial thoughts:
>
> Perhaps exposing parameter names isn't a good idea - perhaps just return
> an array? You could easily pass an array to .bind, .call, etc.
>
> I'm not sure the use cases for such a feature make it worth adding - isn't
> this a problem better solved by documentation? But if it did return an
> array, it might be useful. What are the typical use cases for this in other
> languages?
>
> Also, should this just be a Reflect method or should it also be available
> on Function.prototype?
>
> Thomas
>
> > On 6 Oct 2015, at 1:04 AM, Benjamin Gruenbaum <benjami...@gmail.com>
> wrote:
> >
> > 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:
> >
> > ```js
> > 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
> getters.
> >
> > Is there interest in such an API? Is there any previous work or
> discussions about it?
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss@mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to