Determine The Number Of Arguments A Function Accepts In JavaScript

In this short blog post, we'll understand how we could find the number of arguments a JavaScript function accepts.
 
JavaScript's function object consists of a length property which could be used to get the number of arguments a JavaScript function accepts.
  1. function sum(arg1, arg2, arg3) {  
  2.     return arg1 + arg2 + arg3;  
  3. }  
  4. console.log(sum.length)  
  5. // Output: 3  
In the above code the console.log method will output 3 since the sum function accepts 3 arguments.  
Next Recommended Reading Delegate Function in JavaScript