What is the primary purpose of event delegation in JavaScript?
Event delegation is a pattern where instead of attaching event listeners to individual elements, you attach a single listener to a parent element that handles events on its children (including future children). This approach provides several benefits: 1) Better memory efficiency as it reduces the number of event listeners, 2) Automatic handling of dynamically added elements, 3) Improved performance with large numbers of similar elements, 4) Simplified event management in complex applications.