Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
frwhlr
· 8y ago · 0 comments
I think spamming mutable objects around in your codebase is asking for trouble. I'd be really happy to be able to do something like this:
foo( Object.copy(barObj) );
I mean, why would you send your state's mutable object as argument if you're 100% sure you don't want it to be changed?
Comments
[–]
taco_emoji
8y ago
Because copying is expensive. If mutability is the issue, use Object.freeze(), or define properties with Object.defineProperty() setting
writable
to false.