JS Bin
✓ Published0🌍 Public
Aalessioalex
Last edited Feb 7, 2019
Created on Feb 7, 2019
This example demonstrates a JavaScript function-wrapping utility that intercepts and modifies the behavior of existing functions. The code defines a `wrapper` function, which takes a context object, a function name, and an optional modifier function, then replaces the original function with a proxy that logs arguments or applies custom modifications. Two concrete use cases are shown: wrapping the native `JSON.parse` method to display its arguments in the console, and wrapping a custom `logMsg` function to prepend a prefix to its message. The example uses plain JavaScript (ES5) and relies on the browser console for output.
AI-generated description