Skip to content

Instantly share code, notes, and snippets.

@Arieg419
Last active February 23, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arieg419/d96a44a6c56a187db497a6c54ca7de31 to your computer and use it in GitHub Desktop.
Save Arieg419/d96a44a6c56a187db497a6c54ca7de31 to your computer and use it in GitHub Desktop.
var pokemon = {
firstname: 'Pika',
lastname: 'Chu ',
getPokeName: function() {
var fullname = this.firstname + ' ' + this.lastname;
return fullname;
}
};
var pokemonName = function() {
console.log(this.getPokeName() + 'I choose you!');
};
var logPokemon = pokemonName.bind(pokemon); // creates new object and binds pokemon. 'this' of pokemon === pokemon now
logPokemon(); // 'Pika Chu I choose you!'
@imambungo
Copy link

'this' of pokemon === pokemon now.

Do you mean 'this' of pokemonName === pokemon now?

@xuzheng465
Copy link

'this' of pokemon === pokemon now.

Do you mean 'this' of pokemonName === pokemon now?

I think so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment