I wanted to ask about the pros cons of my the following OOP style. I write my JS classes in the following manner.
var MyClass = function() {
// private vars
var self = this,
_foo = 1,
_bar = "test";
// public vars
this.cool = true;
// private methods
var initialize = function(a, b) {
// initialize everything
};
var doSomething = function() {
var test = 34;
_foo = cool;
};
// public methods
this.startRequest = function() {
};
// call the constructor
initialize.apply(this, arguments);
};
var instance_1 = new MyClass();
var instance_2 = new MyClass("just", "testing");
Is this a good approach? Is there any drawback? I don't use inheritance, but would it work this way to achieve inheritance?
Thanks in advance.