Created
February 11, 2017 04:44
-
-
Save ahmed-anas/2c5d3fe08ff27ffb276d8720677ad3f5 to your computer and use it in GitHub Desktop.
Revisions
-
ahmed-anas created this gist
Feb 11, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ let myObj = { str: 'Original Scope', foo: function() { console.log(`my scope is ${this.str}.`); } } function myBind(func, scope){ for(let prop in scope){ this[prop] = scope[prop]; } this.funcToCall = func; return this.funcToCall; } myObj.foo(); var newFoo = myBind(myObj.foo, {str: 'Overwridden Scope'}); newFoo();