Freezing an instance
Suppose you are writing a program that produces instances that are intended to be used in other programs. You don't necessarily trust that other people will use these objects as you intended - for example, they might overwrite certain properties/methods or write new ones. While you can't keep people from editing the underlying code, you do have some options at runtime (i.e. when the program is run).
The simplest option is to use Object.freeze
on prototype
, so that certain values can't be changed.