Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

get and set in typescript

class ABC {
    private Name: string;

    get name() : string {
        return this.Name;
    }

    set name(setName: string){
        this.Name = setName;
    }
}

let abc = new ABC();
abc.name = "Albert Thomas"; //set property
console.log('My name is ' + abc.name); //get property
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #set #typescript
ADD COMMENT
Topic
Name
9+2 =