th.

Const isn't constant

07 Aug 2024 • 1 min read

In every Javascript app I've worked on, the linter has enforced preference towards const over let. And yet I've always wondered why code like this is valid Javascript:

const user = {
  id: 1234;
}

user.id = 4567;

This lightning talk by Ryan Florence finally made it click–const doesn't create true immutability! It just makes it feel like the code is immutable.

View Link

Want to keep reading?

If you enjoyed this article, you might enjoy one of these:

© 2024 Trevor Harmon