谁能向我解释这段代码?它的含义和使用方法是什么?
Function.prototype.createInterceptor = function createInterceptor(fn) {
var scope = {};
return function () {
if (fn.apply(scope, arguments)) {
return this.apply(scope, arguments);
}
else {
return null;
}
};
};
var interceptMe = function cube(x) {
console.info(x);
return Math.pow(x, 3);
};
//
var cube = interceptMe.createInterceptor(function (x) {
return typeof x === "number";
});