Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JS Wrap Function

var originalFunction = myFunction;
window.myFunction = function myFunction(a, b, c) { /* #1 */
  /* work before the function is called */
  try {
    var returnValue = originalFunction.apply(this, arguments); /* #2 */
    /* work after the function is called */
    return returnValue;
  }
  catch (e) {
    /* work in case there is an error */
    throw e;
  }
}
for(var prop in originalFunction) { /* #3 */
  if (originalFunction.hasOwnProperty(prop)) {
    window.myFunction[prop] = originalFunction[prop];
  }
}
Source by trackjs.com #
 
PREVIOUS NEXT
Tagged: #JS #Wrap #Function
ADD COMMENT
Topic
Name
8+1 =