, , , , ! !
, , ! , :
function thing(a, b, c) {
}
var functionPool = {}
for( var func in window )
{
if (typeof(window[func]) === 'function')
{
functionPool[func] = window[func];
(function(){
var functionName = func;
window[functionName] = function(){
var args = [].splice.call(arguments,0);
if(functionPool[functionName].length > args.length)
throw "Not enough arguments for function " + functionName + " expected " + functionPool[functionName].length + " got " + args.length;
return functionPool[functionName].apply(window, args );
}
})();
}
}
thing(1,2 ,3);
thing(1,2);
:
, , Function.prototype.call. , , . , Function , , eval ! , , , , , . , , , , .
, , javascript - , -, , .