3 ms·
Isn't the JS version just: function f(x, ...args) { return g(x, ...args); } Or did you mean forwarding object fields? function f(x, param
by zeroxfe 7y ago
Isn't the JS version just:
function f(x, ...args) {
return g(x, ...args);
}
Or did you mean forwarding object fields?
function f(x, params) {
return g(x, {foo: 1, ...params});
}
- tomp 7y agoAFAIK the first only works for positional (non-keyword) arguments. The second works, I guess? Not an expert in JS, especially not the "new parts", splats are definitely an improvement!
- garyclarke27 7y agoJS parameters are named to some extent, as in you can refer to them by name within the function body - BUT (a critical shortcoming in my view) you can’t assign values by name when calling functions, you can only assign values by position.