Typescript Properties
Hey there, have you ever come across something like
getY() {return y}
setY(y){this.y = y}
?
Fine, those are the geters and seters you hear about in programming.
They simply help the programmer access the variables in a class whenever they need to use them. Especially when the variables are private to the class.
Now, typescript is funny. Yes, I said funny. It simplifies the two into:
set X(x){this.x = x}
get X() { return y}
Look, I am simply saying that in typescript you can choose to write them normally or like the later. The difference comes in the usage.
Assume the class object is “n” then accessing and returning will be as below:
n.X = ‘Whatever’
y = n.X
And you are done.
Madness, these guys developing programming languages will kill us one day.