0

Can any one explain why TypeError: this.method2 is not a function. As I believe this is not may be the right way to do it.

var _obj = {

    method1: function() {
        console.log("this is form method 1");
    },
    method2: function() {
        this.method1();
    },

    start:this.method2()
};
Igal S.
  • 11,488
  • 4
  • 31
  • 44
Neo S
  • 3
  • 2

1 Answers1

0

You have a simple mistake here, this is how you shoul do it:

var _obj = {

method1: function() {
     console.log("this is form method 1");
},
method2: function() {
     this.method1();
},

start: function(){
  this.method2()
 }
};
squeekyDave
  • 882
  • 1
  • 14
  • 33