It is not clear to me when anyone would need to use Object.freeze
in JavaScript. MDN and MSDN don't give real life examples when it is useful.
I get that part about not being able to change it at runtime which is enforced by a crash. The question is rather when would I appreciate a crash.
To me the immutability is a design time constraint which is supposed to be guaranteed by the type checker.
So is there any point in having a runtime crash in a dynamically typed language, besides detecting a violation better later than never?
question from:https://stackoverflow.com/questions/14791302/why-would-i-need-to-freeze-an-object-in-javascript