JavaScriptIntermediate#dom#events

Difference between stopPropagation and preventDefault?

preventDefault cancels the browser's default action (form submit, link navigation) but the event keeps travelling. stopPropagation stops the event reaching other elements but the default action still happens.

Example
form.addEventListener('submit', e => {
  e.preventDefault(); // stay on the page
  save();
});

Related Questions

1
JavaScriptAdvanced#performance#functions

What is debouncing and throttling?

Open
2
JavaScriptBeginner#arrays

Explain map, filter and reduce.

Open
3
JavaScriptBeginner#arrays

Difference between forEach and map?

Open