function validateArguments(args)
{
if(args.length < 1 && args.length > 2)
{
throw new RangeError("Invalid amount of arguments. Follow the syntax");
}
if(typeof args[0] !== "object")
{
throw new TypeError("Invalid first argument type. Follow the syntax");
}
if(args[1] && typeof args[1] !== "function")
{
throw new TypeError("Invalid second argument type. Follow the syntax");
}
return true;
}
What I'm trying figure out is for args[1]
if it is a function get the arguments list of that as well. Is this possible? Basically, here is an example code.
someFunction({ object:"//object" },function(data,datas,dataCall){
//is data, datas, and dataCall too many arugments.
//if so how to throw the error here
});