3 ms·
I use a similar technique when the number of optional arguments get out of control (i.e. if there is more than one optional argument). If you want to tight con
by willwagner 17y ago
I use a similar technique when the number of optional arguments get out of control (i.e. if there is more than one optional argument). If you want to tight control, you can take advantage of the fact that a variable that is a function, the length member specifies the number of arguments declared as in:
(function(a,b,c){}).length == 3
Using that knowledge, you can do this at the top of a function:
if(arguments.callee.length > arguments.length){
throw "Required Parameter Missing";
}