Question: What are the use cases? An issue with that sort of reflection API, is that it exposes how the function is defined rather than how the function behaves. That makes refactoring more brittle.
—Claude > Le 5 oct. 2015 à 16:04, Benjamin Gruenbaum <benjami...@gmail.com> a écrit : > > 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