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.
  • 13,146
  • 5
  • 30
  • 48
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
  • 918
  • 2
  • 16
  • 35