Code:
  function addMethod(object, name, fn) {
           var old = object[name];
           object[name] = function(){
		if (fn.length == arguments.length)
			return fn.apply(this, arguments)
		else if (typeof old == 'function')
			 return old.apply(this, arguments);
					     };

}
var ninja = {};
addMethod(ninja,'whatever',function(){ var no='no args';return no; });
addMethod(ninja,'whatever',function(a){var one='one args'; return one; });
addMethod(ninja,'whatever',function(a,b){var two='two args'; return two; });
alert(ninja.whatever());
alert(ninja.whatever(1,2));
i dont konw why i call the ninja.whatever function with args ,it response with the corresponding function ? how ?