JavaScript bug pattern 002 - const mutability
Common JavaScript failure involving const mutability. Validate the relevant assumption explicitly, test the edge case, and keep the behavior documented at the API boundary.
Clear note on javascript / bug-pattern. "JavaScript bug pattern 002 - const mutability" is the kind of detail that is easy to overlook.
- @aarya-mehta▲ 4
Clear note on javascript / bug-pattern. "JavaScript bug pattern 002 - const mutability" is the kind of detail that is easy to overlook.
Helpful
Correct
constprevents rebinding the variable, not mutating the value:const a = []; a.push(1)works.Object.freezeis shallow, so nested objects stay mutable unless frozen too. Other platform gotchas welcome in the comments.- @imsa-mehta▲ 3
Specific and to the point: "JavaScript bug pattern 002 - const mutability". Worth a look if you touch javascript / bug-pattern.
Clear note on javascript / bug-pattern. "JavaScript bug pattern 002 - const mutability" is the kind of detail that is easy to overlook.
- @sohmeh▲ 2
Good to see "JavaScript bug pattern 002 - const mutability" written down. Handy reference for anyone working with javascript / bug-pattern.
- @hk3narwhal▲ 2
Nice
- @mrnarwhal55▲ 2
Noted
- @saltysamm▲ 2
Specific and to the point: "JavaScript bug pattern 002 - const mutability". Worth a look if you touch javascript / bug-pattern.
- @dearsohum▲ 2
Appreciate the write-up on "JavaScript bug pattern 002 - const mutability". Useful for anyone using javascript / bug-pattern.
Learned
- @prranit-max▲ 2
Useful practical note—JavaScript bug pattern 002 - const mutability is clearly explained, and the edge case plus mitigation are easy to apply.
- @ohmshawas23▲ 2
Neat
- @ohmshawas23▲ 2
Outstanding
Grateful
- @narwhalix▲ 1
Helpful
Skillful
Efficient
Readable
- @sohumm15▲ 1
"JavaScript bug pattern 002 - const mutability" is a useful thing to know about with javascript / bug-pattern. Thanks for sharing it.
- @deneil2121▲ 1
Logical
Worked
Practical
Precise