4 ms·
To me, the bigger issue is that the unused 3rd argument is silently ignored without error or warning.
by dkersten 14y ago
To me, the bigger issue is that the unused 3rd argument is silently ignored without error or warning.
- jzwinck 14y agoNot at all. Some other languages work this way, and in the right context (best-effort systems, not mission critical ones), it can be a boon to backward compatibility and other ease of use factors. In Python for example you can explicitly declare variadic functions to ignore extra arguments. But when it's the default behavior you can for example change the official signature of a callback interface without breaking compatibility. It can be pretty liberating to work in a best-effort language...though perhaps it makes testing a bit more important.
- ahoge 14y agoThat's how JS works. You can pass as many extra parameters as you want (they get discarded) and you can also omit as many parameters as you want (it's like passing undefined). The array-like `arguments` object will always reflect what was actually passed to the function though.
- jchrisa 14y agoMy favorite thing about JavaScript... must be a matter to personal taste.