Since ES5 we can use Object.freeze()
to lock objects.
But if you run JS in sloppy-mode any writing to the properties fails silently, unless you activate strict-mode.
But where do you need to set this? I use a module system (node.js/amd) so there are a bunch of files/scopes involved:
- Scope where object was created originally.
- Scope where the Object.freeze() was called on the object.
- Scope where an attempt is made to change the object's properties.
- Global scope
- ???
Which one of these MUST have (inherit) a 'use strict' directive to trigger the error?