Methods

  • Objects can have functions that operate on their data
  • These functions are called methods
  • Methods use the special keyword "this"
  • Use the dot operator to call them
const ryan = { 
        firstName: "Ryan", lastName: "Kadri", age: 26,
        getFullName() { return this.firstName + " " + this.lastName },
        birthdayParty() { this.age ++ }
    };
    
    console.log(ryan.getFullName());

15 / 24