Blog o programowaniu, błędach w kodzie, debugowaniu i refaktoryzacji

// Dev notes

function deploySafely()

if (isFriday()) {

console.warn(„Do not touch production.”);

return;

}

deploy();

}

Notatki programistki

Kod jest jak dowcip. Jeśli musisz go wyjaśniać, jest kiepski


Praktyczny kod

Pigułka wiedzy

Clean Up with removeEventListener() to Prevent Memory Leaks

Always clean up listeners to avoid memory leaks – especially in components or SPA apps.

function onClick() {
  console.log('Button clicked!');
}

element.addEventListener('click', onClick);

element.removeEventListener('click', onClick);

Skipping Array Elements with Destructuring

When using destructuring, you can skip the fields you’re not interested in — but you must keep the commas, e.g.:

const [ , second ] = ["Alice", "Olivia", "Ella"];
console.log(second); // "Olivia"

This allows you to “skip” array elements without creating extra variables.

Event propagation

Event propagation is the way events travel through the DOM tree. There are two directions of propagation:

Capturing phase (downward) – the event moves from the document element down to the target element that triggered it.

Bubbling phase (upward) – the event moves from the target element back up the DOM tree until it reaches document.

Blog

Najnowsze posty

Kategoria

JavaScript

Kategoria

Narzędzia Front-end Developera

Kategoria

Linux

Kategoria

CSS