ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

preventDefault vs stopPropagation?

Quick answer

preventDefault cancels the browser's default action; stopPropagation stops the event from travelling further through the DOM.

In detail

`e.preventDefault()` stops the default behaviour (form submit, link navigation) but the event still bubbles. `e.stopPropagation()` halts propagation to ancestors but the default action still happens. They're independent; sometimes you need both.

form.addEventListener("submit", (e) => {
  e.preventDefault();   // don't reload the page
  submitViaAjax();
});

Why interviewers ask this: Commonly confused — interviewers check you know the difference.

This is 1 of 118+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

Full kit

JavaScript Interview Kit · ₹299

Get it →