Encapsulation
Propriétés publiques
function Chien (){
this.nom = "Nom publique";
this.aboyer = function () {
return "Ouaf !!";
}
}
Propriétés privées
function Chien (){
var nom = "Nom privé";
var aboyer = function () {
return "Ouaf !!";
}
}
Méthodes privilégiées
- Peuvent accéder aux propriétés privées tout en étant elles-mêmes d'accès public
function Chien (){
var nom = "Nom privé";
this.aboyer = function () {
return nom + " dit : Ouaf !!";
}
}