Created
October 7, 2025 21:07
-
-
Save voidstar0/179990efe918d1028b72f292cfafe500 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log.toString() // Returns 'function log() { [native code] }' | |
| const consoleHandler = { | |
| get(target, property, receiver) { | |
| if (property === 'log') { | |
| return function(...args) { | |
| const newArgs = ['[LOG]:', ...args]; | |
| return Reflect.apply(target[property], target, newArgs); | |
| }; | |
| } | |
| // For any other property (e.g., 'warn', 'error', 'table'), | |
| // we just want the default behavior. Reflect.get does that. | |
| return Reflect.get(target, property, receiver); | |
| } | |
| }; | |
| window.console = new Proxy(console, consoleHandler); | |
| console.log.toString() // Returns "function(...args) {\n const newArgs = ['[LOG]:', ...args];\n return Reflect.apply(target[property], target, newArgs);\n }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment