function getParameterByName() {
console.log('1');
alert('2');
};
function getParameterByName(){
console.log(“1”);
“);
};
b = getParameterByName.toString();
b=b.replace(/alert\('2'\)/, "");
// 将b转换为函数对象并赋值给c
c = eval('(' + b + ')');
B = getParameterByName.toString();
B=B.replace(/alert\('2 '\)/,“”);
// 将B转换为函数对象并赋值给c
c = eval(“(”+ B +");
const originalFunction = () => {
console.log('Original function');
}
// 创建一个 Proxy 对象来拦截函数的调用
const proxy = new Proxy(originalFunction, {
// 定义拦截处理函数
apply: (target, thisArg, argumentsList) => {
console.log('Before invocation');
// 调用原始函数
const result = Reflect.apply(target, thisArg, argumentsList);
console.log('After invocation');
return result;
}
});
// 调用被代理的函数
proxy();
标签:function,console,函数,alert,控制台,重写,getParameterByName,log
From: https://www.cnblogs.com/byksj/p/17967410