15
I've read a lot of things about the module pattern. Ok It brings structure, private method, etc... But with the code below I can get the same behavior without using it.
function Human()
{
// private properties
var _name='';
var _age=0;
// private methods
function created()
{
console.log("Human "+_name+" called");
};
// public
this.setName = function(name){
_name=name;
created();
};
}
var h1 = new Human();
h1.setName("John");
So, what are the real advantage of a module pattern finally ?