Created
December 26, 2016 23:14
-
-
Save Arieg419/589d90ddf5fc51d99c1c44e77d5907c2 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
var pokemon = { | |
firstname: 'Pika', | |
lastname: 'Chu ', | |
getPokeName: function() { | |
var fullname = this.firstname + ' ' + this.lastname; | |
return fullname; | |
} | |
}; | |
var pokemonName = function(snack, hobby) { | |
console.log(this.getPokeName() + 'I choose you!'); | |
console.log(this.getPokeName() + ' loves ' + snack + ' and ' + hobby); | |
}; | |
var logPokemon = pokemonName.bind(pokemon); // creates new object and binds pokemon. 'this' of pokemon === pokemon now | |
logPokemon('sushi', 'algorithms'); // Pika Chu loves sushi and algorithms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment