-
-
Save botmaster/9369851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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