I know arguments.length method , but this returns the number of arguments the function was called with.
What I need instead is the number of arguments that function requires, so for example
function myFunc(arg1,arg2,arg3) {
alert("number of passed args:" + arguments.length);
alert("number of required args:" + /*the code I'm asking for*/);
};
myFunc('some arg');
So myFunc() would return two alerts saying 1 and 3.
Any way to do that ?
Another, he deprecated
arguments.caller.lengthproperty holds this value.Another method to get the number of formal parameters is by using the
lengthproperty of the function. The function’s name has to be known for this method: