Feb 20
Много бърз и елегантен (според мен) метод, с който можете да имате ‘private’ променливи в клас използвайки Prototype.js
var Person = Class.create({
initialize: function(name, family){
this.getName = function(){
return name;
}
this.getFamily = function(){
return family;
}
// code...code
},
getFullName: function(){
return this.getName() + " " + this.getFamily();
},
// other methods
});
var p = new Person('Radoslav', 'Stankov');
console.log(p.getName(), p.getFamily(), p.getFullName());
