3 ms·
I like JavaScript's (old?) solution to the indexed argument problem: the implicit `arguments` parameter. I haven't bothered looking into the rationale for why t
by ethagnawl 8y ago
I like JavaScript's (old?) solution to the indexed argument problem: the implicit `arguments` parameter. I haven't bothered looking into the rationale for why that wasn't carried over into arrow functions, but I miss it when debugging programs written using ES6.
I'd be interested to know if anything similar was considered during the discussions around adding indexed arguments to Ruby.
- hombre_fatal 8y agoCould you pitch an example where Javascript's `arguments` improves the code? Especially wrt the positional arg syntax at hand? The only use-case I've seen for `arguments` is to create confusing function signatures with no formal arguments. Your linter could prohibit its usage and your code would be better off. Btw, `(...args) => args[0] + args[1]` works. No special `arguments` variable needed. Not sure why you'd do that over `(x, y) => x + y` though.
- ethagnawl 8y agoBesides debugging, I don't know that I've ever used the arguments parameter to do anything useful. I've leaned on underscore/lodash/ramda when doing anything involving clever involving partial application, shuffling arguments, etc. As I mentioned, though, I like/d `arguments` (I don't write much JS these days) because it gives you lots of debugging information with a simple call to `console.log(arguments);` -- made even simpler courtesy of a Vim abbreviation (`autocmd FileType javascript iabbrev adebugger console.log(arguments)`).