Wrapping a function in Javascript / jQuery
问题 If I have an arbitrary function myFunc , what I'm aiming to do is replace this function with a wrapped call that runs code before and after it executes, e.g. // note: psuedo-javascript var beforeExecute = function() { ... } var afterExecute = function() { ... } myFunc = wrap(myFunc, beforeExecute, afterExecute); However, I don't have an implementation of the required wrap function. Is there anything that already exists in jQuery like this (I've had a good look through the docs but cannot see