What do you think of Object.freeze to ensure props don't change over time? I think that is awesome, but never saw it anywhere,... and people rather use libs like immutable.
I was originally going to talk about freezing but then I decided to scope the article down to only the bare essentials.
I know if you do a freeze on the whole class instance it has weird effects on subclasses and inheritance in general. But it is a pretty good idea to "ensure" that nobody can mutate stuff.
I do think that in some cases you might want to keep your classes mutable though. Just depends on the use case and what you're using them for.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What do you think of
Object.freeze
to ensure props don't change over time? I think that is awesome, but never saw it anywhere,... and people rather use libs likeimmutable
.I was originally going to talk about freezing but then I decided to scope the article down to only the bare essentials.
I know if you do a freeze on the whole class instance it has weird effects on subclasses and inheritance in general. But it is a pretty good idea to "ensure" that nobody can mutate stuff.
I do think that in some cases you might want to keep your classes mutable though. Just depends on the use case and what you're using them for.