Skip to content

Instantly share code, notes, and snippets.

@AkashRajvanshi
Created September 26, 2019 07:19
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 AkashRajvanshi/d119d488ce87e9a6d510c436497dd995 to your computer and use it in GitHub Desktop.
Save AkashRajvanshi/d119d488ce87e9a6d510c436497dd995 to your computer and use it in GitHub Desktop.
function Person(firstName, lastName) {
this.first_name = firstName
this.last_name = lastName
this.showDetails = function () {
console.log(`Name: ${this.first_name} ${this.last_name}`) // Name: Akash Rajvanshi
}
}
const person = new Person('Akash', 'Rajvanshi')
person.showDetails.bind(person)() // This is immediately invoked
const showDetailsOfPerson = person.showDetails.bind(person) // We can invoke this function later
showDetailsOfPerson()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment