3 ms·
Why not just Object.freeze()?
by blauditore 9y ago
Why not just Object.freeze()?
- johnhenry 9y agoFreezing an object doesn't freeze it's children, and thus it's still technically mutable. I think using deep-freeze (https://github.com/substack/deep-freeze https://github.com/substack/deep-freeze) might work.
- irishsultan 9y agoBecause that doesn't do what people want/expect, if you have a key with a value that's not frozen it will still be mutable, which indirectly mutates your object. See the example at https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze https://developer.mozilla.org/en/docs/Web/JavaScript/Referen... about modifying internal.a