Skip to content

Instantly share code, notes, and snippets.

@botmaster
Forked from zouloux/SolidConvention
Created March 5, 2014 15:49
Show Gist options
  • Save botmaster/9369851 to your computer and use it in GitHub Desktop.
Save botmaster/9369851 to your computer and use it in GitHub Desktop.
// Déclaration d'une classe
var MyClass = function (pParam1, pParam2)
{
// Scope fake publique
var that;
// Propriété privée
var _privateVar = 5;
// Méthode privée
var _privateMethod = function (pParam1)
{
console.log("Private called", pParam1, MyClass.staticProp);
that.otherPublicMethod();
};
// Implémentation des méthodes publiques dans le scope fake
that = {
construct: function ()
{
console.log("Construct", pParam1, pParam2);
that.otherPublicMethod();
},
checkName: function ()
{
_privateMethod(_privateVar);
return "PublicReturn";
},
otherPublicMethod: function ()
{
console.log("otherPublicMethod");
}
};
// Lancer le constructeur
that.construct();
// Retourner le scope fake public
return that;
}
MyClass.staticProp = 6;
var myInstance = new MyClass("pascal", "achard");
myInstance.checkName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment