function inside object js code example
Example 1: js functions inside of objects
var person = {
name: "Fred",
sayName: function() {
console.log(this.name);
}
};
person.sayName();
Example 2: function inside object javascript
var obj = {
func: function(a, b) {
return a * b;
}
};
obj.func(3, 6); // 18