I am trying to call the function MyMethod from within a object but none of the syntax below works.
There must be a really obvious error below but I can\'t see it.
var MyObject = function MyObject() {
this.MyMethod = function () {
alert('It works');
} }
var test = new MyObject(); test.MyMethod();
The above will do. Or you can just create a constructor and call this method inside that. So at the time of object creation it will call this.MyMethod()