3 ms·
In JS, sending the "wrong" number of arguments is frequently a feature. There's no concept of language-level function overloading, and it allows for the authors
by potch 13y ago
In JS, sending the "wrong" number of arguments is frequently a feature. There's no concept of language-level function overloading, and it allows for the authorship of functions that take a variable or unbounded number of arguments (useful when coding in a functional paradigm).
- admnor 13y agoThat "feature" would be better with an explicit language construct such as *args or params args[], though. As with so many complaints about JavaScript, it's the default behaviour that is a problem.
- Peaker 13y agoI'd say it's worse than a default behavior, since there's no sane way to reverse the default. Are explicit arg list checks really an option, when you want to opt out of the default? I'd say that's not practical at all -- so it's really worse, as there's no practical opt out of this.
- jakub_g 13y agoES6 brings "rest parameter" [0]. function(param1, param2, ...rest) {} [0] http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html http://ariya.ofilabs.com/2013/03/es6-and-rest-parameter.html