MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/btxz72/what_are_some_javascript_things_beginners_dont/ep8kjl2
r/javascript • u/[deleted] • May 28 '19
383 comments sorted by
View all comments
Show parent comments
3
But even Object.freeze won't freeze deeply - i.e,
const obj1 = { obj2: { foo: "bar" } } Object.freeze(obj1); obj1.obj2 = {foo: 'baz'} // noop console.log(JSON.stringify(obj1)) // -> {"obj2":{"foo":"bar"}} obj1.obj2.foo = 'baz' // legal. console.log(JSON.stringify(obj1)) // -> {"obj2":{"foo":"baz"}}
This is why the Immutable.js library is a thing.
1 u/starm4nn May 29 '19 Doesn't freeze mean performance loss?
1
Doesn't freeze mean performance loss?
3
u/[deleted] May 29 '19
But even Object.freeze won't freeze deeply - i.e,
This is why the Immutable.js library is a thing.