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



Smartphone icons created by Freepik - Flaticon

JS Functions

This example calls the fullName method of person, using it on person1:

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

const person1 = {
  firstName:"John",
  lastName: "Doe"
};

const person2 = {
  firstName:"Mary",
  lastName: "Doe"
};

document.getElementById("demo").innerHTML = person.fullName.call(person1, "Oslo", "Norway");