Created
December 19, 2014 19:42
This file contains 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 bind2(fun, obj) { | |
return function() { | |
fun.call(obj); | |
}; | |
} | |
function displayName() { | |
console.log(this.name); | |
} | |
var obj1 = {name: "Deepak"}; | |
var obj2 = {name: "Chetan"}; | |
var displayName = bind2(displayName, obj1); | |
displayName(); // "Deepak" | |
displayName.call(obj2); // "Deepak" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment