itβs bad practice to write code that is hard to read and hard to understand, maintain or use others.
good practice allows you to specify named arguments and give them meaningful, useful, descriptive names when possible.
In addition, you must remember that you can declare named arguments, even if all of them are not required. You can then check arguments.length to see how many arguments were passed, or check the values ββof specific named arguments to see if they are undefined or not.
In the case of strongly variable arguments, you can also pass the object and let the object independently describe which arguments were passed.
There are specific cases where an argument object is useful, and using it is the best way to write clear, concise, and safe code, but I have never seen a case where all functions declare named arguments and use only the arguments to the object. Unless you have a very unusual project, this is usually not the best way to code so many functions.
For performance, it seems that access to named arguments is also faster than access to the arguments object in all major browsers. In this performance test, jsperf , which simply sums up the first three arguments passed to the test function using named arguments , is 2-8x faster than using the arguments object. The exact performance difference depends on what the function is trying to execute, but the arguments object definitely looks slower.
If you provide more details on why you want to use the arguments object instead of named arguments, or why you think it would be useful to use the arguments object, then we could offer more specific recommendations.
source share