ginebra2/chrome/js/Bind.js
author hgs
Tue, 29 Jun 2010 00:46:29 -0400
changeset 3 0954f5dd2cd0
parent 0 1450b09d0cfd
permissions -rw-r--r--
201026


// 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;
}