3 ms·
At first, this sounds like the familiar blues of “I got bit by an immutable reference to a mutable object”, but something seems...off. Const in JS is an immutab
by dragonwriter 6y ago
At first, this sounds like the familiar blues of “I got bit by an immutable reference to a mutable object”, but something seems...off. Const in JS is an immutable reference that doesn't change the mutability of the value referenced, so an object will be mutable though you can't reassign a different object.
By JS strings are immutable, and String.prototype.replace doesn't modify in place, it returns a fresh string. So, this shouldn't be possible as described.