The Event Object — JS Technical Interview Questions & Answers
target, type and other event metadata.
The Event Object
- The Event Object (js) is a JS topic. In plain words you use it for { name, marks } in a student record. Don’t start with a slogan — start with that picture.
- Smallest example: const { name } = student. Type it, run it, and say what you see. If you can do that from memory, you know The Event Object (js).
- From the example next to this theory: target, type and other event metadata.
- Trap: copying nested objects by accident (shallow copy). Fix that before you talk about advanced JS.
- Viva: what is The Event Object (js)? Then show const { name } = student. Then name the trap.
Technical Interview Tip: What is The Event Object (js)? Show this: const { name } = student. Trap: copying nested objects by accident (shallow copy).
Code Examples for The Event Object
The Event Object — working example
// Browser delegation sketch:
// list.addEventListener("click", (e) => {
// if (e.target.matches("button.del")) {
// e.preventDefault();
// e.target.closest("li")?.remove();
// }
// });
// Runnable stand-in:
function onClick(e) {
if (e.target === "del") {
e.preventDefault?.();
return "removed";
}
return "ignored";
}
console.log(onClick({ target: "del", preventDefault() { this.ok = true; } }));The Event Object — listeners react to events; delegation handles many children from one parent; preventDefault stops default browser action.
How to Explain The Event Object to an Interviewer
What is The Event Object (js)?
Used for { name, marks } a student record Not just the heading
Give one small example of The Event Object (js).
const { name } = student target, type and other event metadata
What mistake do beginners make with The Event Object (js)?
copying nested objects by accident (shallow copy) Show the fix
Where do you use The Event Object (js)?
a student record { name, marks }