6 Staying immutable in a mutable language

Image

In this chapter

  • Apply a copy-on-write discipline to ensure that data is not changed.
  • Develop copy-on-write operations for arrays and objects.
  • Make copy-on-write work well for deeply nested data.

We’ve been talking about immutability, and we’ve even implemented it in some places. In this chapter, we’re going to dive deep. We’ll learn to make immutable versions of all of the common JavaScript array and object operations we’re used to using.

Can immutability be applied everywhere?

We’ve already implemented some shopping cart operations using a copy-on-write discipline. Remember: That means we made a copy, ...

Get Grokking Simplicity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.