I need help with using Prototypes, I'm trying to organize and maintain a cleaner code and can re-use my classes at other times ... And in research, using Prototype seems to be advantageous ... (I can have corrected wrong, correct me ...)
Firstly I will put my code below and follow my doubts ...
var Model = function(hello) {
this.hello = hello;
//meu teste
this._init();
}
Model.prototype = function(){
var _init = function(){
console.log("Init...");
this.helloWorld();
},
_helloWorld = function(){
alert(this.hello)
};
return {
helloWorld : _helloWorld
};
}();
1st Doubt: Inside my Builder how could I call my "_init" function? Since it is private, I would like to have the first call inside the constructor. In my example above, I made the call via "this._init ()", but I had the error:
Uncaught TypeError: this._init is not a function
2nd Doubt: Within my "_init" function will I be able, and I will have calls from other methods, in this example: "_helloWorld", the form I did would work? Or the right way?
Thank you.