Using Object Methods in Javascript


Define and call functions (methods) within objects.

Source Code

let person = {
  name: "John",
  greet: function() {
    console.log("Hello, " + this.name);
  }
};
person.greet(); // "Hello, John"
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments