parent.addEventListener('click', function handler(e) {
console.log('Clicked');
this.removeEventListener('click', handler);
});
This code demonstrates a self-removing event listener pattern, where the listener removes itself after executing once. This is similar to using the once: true option but provides more control over when the removal occurs. This pattern is useful when you need more complex logic to determine when to stop listening, or when you need to perform cleanup operations before removing the listener. Note that using an arrow function would not work here as 'this' would not refer to the element.