[Solved] METHODS IN JAVASCRIPT [closed]


Like this using inline object

var object = {
   method: function() {
       console.log('this is method');
   }
};

object.method();

using contructor:

function Foo() {
    this.method = function() {
        console.log('this is method');
    };
}
var object = new Foo();
object.method();

using prototype:

function Foo() {}

Foo.prototype.method = function() {
    console.log('this is method');
};
var object = new Foo();
object.method();

solved METHODS IN JAVASCRIPT [closed]