Skip to content

Instantly share code, notes, and snippets.

@ranamahmud
Last active November 7, 2020 08:16
Show Gist options
  • Save ranamahmud/01fc5c789cf977a2789057aa04c7fb2d to your computer and use it in GitHub Desktop.
Save ranamahmud/01fc5c789cf977a2789057aa04c7fb2d to your computer and use it in GitHub Desktop.
const dog = {
name: 'Dog',
getName: function () {
return this.name;
},
bark: function () {
console.log(this.name + ". Bark bark ...")
}
}
dog.bark();
// Dog. Bark bark ...
const bullDog = {
name: 'BullDog'
}
const bullDogBark = dog.bark.bind(bullDog);
bullDogBark();
// BullDog. Bark bark ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment