Skip to content

Instantly share code, notes, and snippets.

@ahmarsuhail
Created July 16, 2019 18:28
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 ahmarsuhail/61a868a5f381fc3cacdb3aac50f188d1 to your computer and use it in GitHub Desktop.
Save ahmarsuhail/61a868a5f381fc3cacdb3aac50f188d1 to your computer and use it in GitHub Desktop.
const user = {
name: "Ahmar",
printName: function() {
console.log(this.name);
}
}
const printNameOutsideOfObject = user.printName
const boundFunction = printNameOutsideOfObject.bind(user);
boundFunction(); //Outputs: Ahmar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment