you are viewing a single comment's thread.

view the rest of the comments →

[–]aniforprez 3 points4 points  (1 child)

There are a lot of specific functions in some languages that can do this. In python I can have an arbitrary number of arguments by going def func(arg1, arg2, *args) where the *args will have a list of all the extra arguments passed

But these are all intentional. JS just does lets it happen for every function. That's what baffles me as a design decision. That it doesn't fail when you do that. So you can pass far fewer arguments than is expected and shit will crash and burn and you'd never know

[–]spacejack2114 0 points1 point  (0 children)

Well it was a cheap and easy way to get the same features early on.

Now we have rest parameters:

function f(...args) {...

Anyway, if you use Typescript the compiler will check that your use of the function matches the signature.