Fields


Accessing - Using Public


function class_Example(name, address) { 
   // public fields
   this.name = name;
   this.address = address;
}
var myObject = new class_Example("one","two");
var string1 = myObject.name


Accessing - Using Methods

This uses private fields

function class_Example(name, address) { 
   // private fields
   var privateString = "some text";
    // assuming that this variable is used inside one of the class methods.
}
var myObject = new class_Example("one","two");
var string1 = myObject.name



Accessing - Using Properties


var myObject = { 
   Property1 : 10,
   get Property1_Get() {
      return this.Property1;
   }
}


var myObject = { 
   Property1 : 10,
   set Property1_Set(val) {
      this.Property1 = val;
   }
}






© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext