I was looking at the JQuery and SignalIR sourcecode and I can say the I was intrigued by how they implemented a OOP Pattern. so I created my own simple object to show this
var Andromeda = (function() {
// Factory method
var Andromeda = function () {
return new Andromeda.fn.init();
}
Andromeda.fn = {
// Constructor
init : function() {
},
property : 0,
method : function() {
var me = this;
alert(me.property);
}
};
Andromeda.fn.init.prototype = Andromeda.fn;
return Andromeda;
}());
To call methods
var a = Andromeda(); a.property = 1; a.method(); var b = Andromeda(); b.property = 2; b.method();
Happy coding…