So, I would like to have some code executed everytime a given function is called, is that doable? Thing is, I could just overwrite the existing function and add the code, but that would require me to know the exact content of that function… Imagine a “plug-in” to a “library”, and you want the plug-in to execute code everytime a specific function of this librairy is called, but you don’t want to overwrite the original librairy content… Hope I’m clear enough!
And if it is doable, is there a way to retrieve the arguments submitted to the function?
It’s definitely doable. JS is a dynamic language, so you can swap a function stored in an object with your own. For example: