Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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});
    }


JS 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.


AFAIK 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!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: