Tip: Click lines to highlight, hold ctrl/cmd to multi-select

javascript pointcut example (11-Nov @ 10:56)

This example intercepts the jQuery bind event and logs the number of calls

www.flickr.com-photos-bjarlestam

Syntax Highlighted Code

  1. /* This will intercept the jQuery bind event
  2.  * and logs the number of calls
  3.  */
  4. jQuery.fn.bind = function (bind) {
  5.      return function () {
  6.           console.count("jQuery bind count");
  7.           console.log("jQuery bind %o", this);
  8.           return bind.apply(this, arguments);
  9.       };
  10. }(jQuery.fn.bind);

Plain Code

/* This will intercept the jQuery bind event 
 * and logs the number of calls
 */
jQuery.fn.bind = function (bind) {
     return function () {
          console.count("jQuery bind count");
          console.log("jQuery bind %o", this);
          return bind.apply(this, arguments);
      };
}(jQuery.fn.bind);

Codedump Run

Permalink: http://codedumper.com/javascript-pointcut-example