Last active
August 29, 2015 13:57
-
-
Save dagda1/9365057 to your computer and use it in GitHub Desktop.
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
var Person = function(name) { | |
this.name = name; | |
}; | |
var sayHello = function() { | |
console.log("Hello, my name is " + this.name); | |
}; | |
var bob = new Person('Bob'); | |
var paul = new Person('Paul'); | |
var sayHelloBob = sayHello.bind(bob); | |
var sayHelloPaul = sayHello.bind(paul); | |
sayHelloBob(); // Hello, my name is Bob | |
sayHelloPaul(); // Hello my name is Paul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment