//Using the principle of data hijacking, ES6 proxy can also be implementedletbValue=1;Object.defineProperty(window,"a",{get(){returnbValue++;}});if(a==1&&a==2&&a==3){console.log("Hello World!");}
leta=[1,2,3];//Use the array method shift to override toString, take the first element of the array and returna.toString=a.shift;if(a==1&&a==2&&a==3){console.log("Hello World!");}//Override toString methodleta={bValue:1,toString:()=>{returna.bValue++;}}if(a==1&&a==2&&a==3){console.log("Hello World!");}
Object.valueOf()
leta=[1,2,3];//Use the array method shift to override valueOf, take the first element of the array and returna.valueOf=a.shift;if(a==1&&a==2&&a==3){console.log("Hello World!");}/ **
*OverridevalueOfmethod*/leta={bValue:1,valueOf:()=>{returna.bValue++}};if(a==1&&a==2&&a==3){console.log("Hello World!");}
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)