Created
January 23, 2016 09:58
-
-
Save pangers/208be119f0797a4ac5d9 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 footballer = { | |
name: "Leo Messi" | |
}; | |
var basketballer = { | |
name: "Steph Curry" | |
}; | |
var fighter = { | |
name: "Conor McGregor" | |
}; | |
function giveMeTheName(occupation) { | |
return this.name + ", " + occupation; | |
} | |
giveMeTheName.apply(footballer, ["the footballer"]); //returns Leo Messi, the footballer | |
giveMeTheName.call(basketballer, "the basketballer"); //returns Steph Curry, the basketballer | |
giveMeTheName.bind(fighter)("the fighter"); // returns Conor McGregor, the fighter | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment