aop实现
Function.prototype.before = function (beforefn)
{
var _self = this;//记录原函数
return function ()
{
beforefn.call(this, arguments);//修正this值
return _self.apply(this, arguments);
}
}
Function.prototype.after = function (afterfn)
{
var _self = this;//
return function ()
{
var ret = _self.apply(this, arguments);//修正this值,并且执行原函数
afterfn.apply(this, arguments);
return ret;
}
}