JSFiddle - React, Tailwind, and code Playground

by amir_ch

JavaScript

// option 1
function AdInfo(id, name) {
     this.ID = id;
     this.Name = name;
};

AdInfo.prototype = {
   get Type() { 
      return this._type;
   }, 
   set Type(val) { 
      this._type = val;
   }
};
    
var ad = new AdInfo(12345,"my ad");    
ad.Type = "Expandable";
    
alert(ad.Name + " , " + ad.Type);    

// option 2
function AdInfo2(id, name) {
   this.ID = id;
   this.Name = name;
   this.__defineGetter__("Type", function() { 
      return _type;
   }); 
   this.__defineSetter__("Type", function(val) { 
      _type = val;
   });
}
    
var ad2 = new AdInfo2(12345,"my ad2");    
ad2.Type = "Expandable";
    
alert(ad2.Name + " , " + ad2.Type);