function bind(method, obj, param1, param2, param3) { var retVal = function() { method.call(obj, param1, param2, param3) }; return retVal; }
Here's some test code, just to get the idea
function Blah() {} Blah.prototype.blah = function(param) { alert("param=" + param + " thing=" + this.thing); }; Blah.prototype.thing = "this is the thing" b = new Blah() window.setTimeout(bind(b.blah, b, "some-param"), 10);Example is not the best, but the bind method is solid.
No comments:
Post a Comment