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

Boost Scroll Performance with passive: true

Make scroll or touch listeners more performant – tell the browser you won’t call preventDefault()

window.addEventListener(
  'scroll',
  onScroll,
  { passive: true }
);

Destructure and Keep the Rest

You can combine destructuring and rest syntax to extract what you need and keep the rest.

const { id, ...info } = { id: 1, name: "Alice", role: "Admin" };
console.log(info);      // { name: "Alice", role: "Admin" }

Run an Event Listener Just Once

You can make an event listener run only once – it removes itself automatically after the first trigger.

button.addEventListener(
  'click',
  handler,
  { once: true }
);

Blog

Najnowsze posty

Kategoria

JavaScript

Kategoria

Narzędzia Front-end Developera

Kategoria

Linux

Kategoria

CSS