3 ms·
that's only because js is "stupid" if you have the string "hello" and somewhere else "hello world" you can retain only one copy of "hello" because it's guarant
by peoplefromibiza 5y ago
that's only because js is "stupid"
if you have the string "hello" and somewhere else "hello world" you can retain only one copy of "hello" because it's guaranteed it won't change.
but js vm it's not smart enough for that.
- __s 5y agoYou're wrong, JS has immutable strings & so VMs use ropes to make mutable usage & slicing fast https://gist.github.com/mraleph/3397008 https://gist.github.com/mraleph/3397008 https://twitter.com/rauschma/status/1269964154275799041 https://twitter.com/rauschma/status/1269964154275799041
- peoplefromibiza 5y agothanks my bad, I learned something new. anyway this proves that immutable data structures are not inherently slow, this is infact an optimization that makes things faster.