Ad
  • Custom User Avatar

    Are you sure about the syntax of that last paragraph? Didn't you mean to write

    foo = foo.wrap(function (original) {
      // do some enhanced functionality...
      original();  // now call the original
    })
    
  • Custom User Avatar

    So that it takes any function and wraps it. Basically its a way to override an existing function. Useful in cases such as:

    function foo(){
      // does something
    }
    
    // later on we want to enhance foos behavior... normally we would have to do this:
    
    var _foo = foo
    foo = function(){
      // do some enhanced functionality...
      _foo(); // now call the original
    }
    
    // but with wrap we could instead do this:
    
    foo = foo.wrap(original){
      // do some enhanced functionality...
      original();  // now call the original
    }
    
  • Custom User Avatar

    The pascal casing is determined by the capitalization of the first word, not underscore vs dashes. I'll update the description to be more clear.