Created
May 30, 2014 18:39
-
-
Save blake41/3b718dbb23c2981874a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.bind = function(that) { | |
var args = Array.prototype.slice.call(arguments) | |
return function() { | |
this.call(that, args) | |
} | |
} | |
var myobj = { | |
name : "blake", | |
colors : ["blue", "purple"], | |
forEach : function(array, action) { | |
for (var i = 0; i < array.length; i++) | |
action(array[i]); | |
}, | |
calculate : function() { | |
this.forEach(this.colors, (function(e) {console.log(this.name)}).bind(this)) | |
} | |
} | |
myobj.calculate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment