Kind of related to what you just learned about access modifiers is another modifier and that's the read
only modifier.
Let's say we have certain fields which should not just be private or public.
They also shouldn't change after their initialization.
For example the I.D. should not change their offer to make it clear that it shouldn't change.
You can add read only here as well and you could have added that up here as well.
So here you would have all the written Private Read only know the read only keyword.
Just like private and public is introduced by typescript.
It does not exist in JavaScript.
It makes sure that if you tried to write to this property thereafter you fail so you can only use it
once during initialization but thereafter.
Let's save for ad employee for whatever reason I tried to change ideas to D2.
You see we get an error here that I can't assign to I.D. because it's read only so does add some extra
safety to make it really clear that a certain property should only be initialized to once and shouldn't
change their offer.
A requirement you have quite often for certain properties in your objects so this can add extra type
safety again and make your intentions very clear.
Of course you can always say well I'm the one writing the code.
I won't do anything I don't want.
Well it's still good to be very clear when you define your code because A you might forget what you
wanted to do.
If you paused working on your code for a couple of weeks or whatever it is and B you might be working
in a team or sharing your code with our people and it's generally a good idea to write clearer and explicit
code that makes our intentions very clear and read only can help you there because it makes it very
clear what your goal is.
If we have a look at app yes as I mentioned we see neither private nor public nor read only because
that all only exists in typescript not in JavaScript.
We also see something different which is also interesting.
The methods are added to the prototype of our constructor function.
Now for this you need to know what prototypes are and introducing those in this course would be a little
bit too much attached you find some resources where you can dive into prototypes.
It's an important part of JavaScript especially of JavaScript.
Before we had classes and it doesn't hurt to understand prototypes if you're a javascript developer
still here I will not dive deeper into them because it's a pure Javascript topic not specific to typescript.
Indeed in typescript we typically work less with prototypes because we can do more with classes and
related to that.
We got another important class concept inheritance.