equal
deleted
inserted
replaced
1 |
1 |
|
2 // Bind a function’s scope at definition instead of execution. Useful |
|
3 // for controlling the 'this' pointer in callbacks. |
2 Function.prototype.bind = function(obj) { |
4 Function.prototype.bind = function(obj) { |
3 var method = this, |
5 var method = this, |
4 temp = function() { |
6 temp = function() { |
5 return method.apply(obj, arguments); |
7 return method.apply(obj, arguments); |
6 }; |
8 }; |
7 |
9 |
8 return temp; |
10 return temp; |
9 } |
11 } |
10 |
12 |
11 function createDelegate(object, method) { |
13 function createDelegate(object, method) { |
12 var shim = function() |
14 var shim = function() |
13 { |
15 { |
14 method.apply(object, arguments); |
16 method.apply(object, arguments); |