This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.



Smartphone icons created by Freepik - Flaticon

JS Function bind()

This example creates 2 objects (person and member).

The member object borrows the fullname method from person:

const person = {
  firstName:"John",
  lastName: "Doe",
  fullName: function() {
    return this.firstName + " " + this.lastName;
  }
};

const member = {
  firstName:"Hege",
  lastName: "Nilsen",
};

let fullName = person.fullName.bind(member);

document.getElementById("demo").innerHTML = fullName();