function factorial(num){ debugger return num==1?1:num*factorial(num-1); } let proxy=new Proxy(factorial,{ apply(func,obj,args){ debugger console.time("run"); func.apply(this,args); console.log(this); console.timeEnd("run"); } }); proxy.apply({},[1000]);
const lessons=[ {title:"124"}, {title:"365"}, {title:"12564"}, ]; let proxy1=new Proxy(lessons, { get(array,key){ debugger const tilte= array[key].title; return tilte; }} ) console.log(JSON.stringify(proxy1[1],null,2));
https://www.jianshu.com/p/77eaaf34e732