function inside object javascript

JavaScript
var obj = {
  func: function(a, b) {
    return a * b;
  }
};

obj.func(3, 6); // 18var person = {
  name: "Fred",
  sayName: function() {
    console.log(this.name);
  }
};

person.sayName();
Source

Also in JavaScript: