How many ways do we have to apply a method in an object to another object in javascrippt? code example
Example 1: function inside object javascript
var obj = {
func: function(a, b) {
return a * b;
}
};
obj.func(3, 6); // 18
Example 2: adding function to objects js
var myObj = {
myFunc: function(param){
//do stuff
}
}