Design Patterns · Junior · Question 24 of 75
Why do you need the Flyweight pattern?
- ✓Correct answer: To save memory by sharing a common immutable part among many objects
- 2To reduce JS bundle size through minification and compression
- 3To speed up image loading by compressing them into modern formats
Explanation
If 100,000 objects share a lot of identical data (an icon, a style, a type description), the shared part is stored once, and objects keep only their unique fields. JS strings and primitives partly use a similar technique.