Freezing an object with a closure

You can theoretically achieve the same result as Object.freeze by creating a closure with another class.

This is not a very scalable way to hide data - you may be interested to learn about Proxies.

Was this page helpful?