JavaScript DOM Scripting By Example Adding and Removing Names RSVP Checkbox

hector alvarado
hector alvarado
15,781 Points

Why did you use event?

I don't understand when we create the second event listener why we use event.target when we create the checkbox variable, for me in my console apeer broken, so instead I used e.target and the event was referenced fine, whi did you use event?

1 Answer

Daniel Phillips
Daniel Phillips
17,928 Points

I think Guil might have made a mistake there. Since he defined the event as e in the event handler function definition, he should have used e.target. He used event.target and it worked because even though you assign a pointer to the event object named e, the event object will always have the event pointer that can also be used. Therefore it works with e or event because e === event. When you tried to access the event object in the console, I'm guessing you didn't use the developer tools to pause during the event (don't ask me how to do that). If that is true, the event wasn't going when you were trying to access event.target in the console so event didn't exist at that time.