...
/Tip 15: Create Maps Without Side Effects
Tip 15: Create Maps Without Side Effects
In this tip, you’ll learn how to avoid side effects by creating new maps from an array of pairs.
We'll cover the following...
Copying & mutation in maps
Up to this point, you’ve always worked on a single instance of a map. You’ve either added data or removed data directly from an instance of a Map object.
Working on the instance of a map can lead to a few problems. How do you create copies of a map? How can you make changes without side effects?
Fortunately, you can solve those problems by applying a few principles you’ve learned from arrays and objects.
To start, look at an example that combines the problems of copying and mutations: applying a set of defaults to a map.
Example: Applying defaults to a map
In your pet adoption code, you have filters that ...
Access this course and 1400+ top-rated courses and projects.