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

Reply via email to