JSFiddle - React, Tailwind, and code Playground
by bogdan_vq
JavaScript
var MyClass = (function(){
function contructor (nume, prenume){
//private members
var prenume = "";
//public fields
this.nume = nume;
this.setPrenume = function(pp) {
prenume = pp;
};
this.getPrenume = function() {
return prenume;
}
};
//static method
contructor.rum = function(){
console.log('static method');
}
// public method
contructor.prototype.printNumeIntreg = function() {
console.log(this.nume + " " + this.getPrenume());
};
return contructor;
})();
var ob = new MyClass("nicu");
console.log(ob.nume);
ob.setPrenume("popescu");
ob.printNumeIntreg();
ob.nume = "gigi";
ob.printNumeIntreg();
MyClass.rum();
var oc = new MyClass("alina");
oc.printNumeIntreg();
MyClass.rum();