Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.