I'm trying to use OOP in JavaScript, and from what I can tell there's a couple of different ways of doing that. With the one I'm using, I'm having difficulty calling an object's method within itself.
This style of OOP is the one that has everything I need in it, so the other styles are off the cards.
function Node(message,options) {
this.message = message;
this.options = options;
this.activate = function() {
SendMessage(message);
this.specialInstructions();
}
this.getMessage = function() {
return this.message;
}
this.getOptions = function() {
return this.options;
}
this.specialInstructions = function() {
SendMessage("Test");
}
}
Here I'm trying to execute specialInstructions()
inside of activate()
, but whenever I try that it says it's undefined.