【发布时间】:2015-08-04 07:58:01
【问题描述】:
如何将代码添加到保留旧功能的函数中
SomeFunction = function () {
someOtherFunction();
return this.apply(this, arguments);
};
【问题讨论】:
标签: javascript delegates
如何将代码添加到保留旧功能的函数中
SomeFunction = function () {
someOtherFunction();
return this.apply(this, arguments);
};
【问题讨论】:
标签: javascript delegates
就这样
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);
};
【讨论】: