I have written a program with lots of functions and function calls. I would like to be able to call code just before every function call. For example, each time a function is called, have the console log
console.log("A function has been called!");
I would like to write this once and for all, not go through every function declaration. I guess this is similar in spirit to the CSS pseudo elements :before and :after, but applied to function calls in JavaScript.
You’re basically looking for Aspect-Oriented Programming in JavaScript. See Javascript AOP libraries.
More questions: https://stackoverflow.com/questions/tagged/javascript+aop