ginebra2/chrome/js/Bind.js
author hgs
Fri, 06 Aug 2010 17:23:08 -0400
changeset 9 b39122337a00
parent 3 0954f5dd2cd0
permissions -rw-r--r--
201031


// Bind a function’s scope at definition instead of execution.  Useful
// for controlling the 'this' pointer in callbacks.
Function.prototype.bind = function(obj) {
    var method = this,
    temp = function() {
        return method.apply(obj, arguments);
    };

    return temp;
}

function createDelegate(object, method) {
    var shim = function()
        {
            method.apply(object, arguments);
        }

    return shim;
}