Javascript JS授权/扩展aleady现有功能
如何向函数添加代码以保留其原有功能Javascript JS授权/扩展aleady现有功能,javascript,delegates,Javascript,Delegates,如何向函数添加代码以保留其原有功能 SomeFunction = function () { someOtherFunction(); return this.apply(this, arguments); }; 就这样 var delegate = functionToBeDelegated; functionToBeDelegated = function () { // // Add functionality to the function /
SomeFunction = function () {
someOtherFunction();
return this.apply(this, arguments);
};
就这样
var delegate = functionToBeDelegated;
functionToBeDelegated = function () {
//
// Add functionality to the function
//
// run the old version of the function in native scope
return delegate.apply(this, arguments);
};