Check out example codes for "typescript variable getter". It will help you in understanding the concepts better.

Code Example 1

class MyClass { 
    private _with:number = 5; 
    private _height:number = 10; 
    get square() { 
        return this._with * this._height; 
    } 
} 
console.log(new MyClass().square);

Learn ReactJs, React Native from akashmittal.com