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 <benjamingr at 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 at mozilla.org>https://mail.mozilla.org/listinfo/es-discuss