JavaScript

Language for web apps, APIs, and edge runtimes.

Why JavaScript matters

JavaScript started as a browser language and became the common API of both frontend and backend when Node.js matured. The modern ecosystem encourages shared contracts across UI and server code.

Core mindset

  1. Prefer immutable patterns in UI components.
  2. Split concerns: presentation, state, API, utility.
  3. Always narrow and validate input from external systems.
  4. Control side effects with explicit state handlers.

Mini async example

async function retryFetch(url, retries = 3) {
  for (let attempt = 0; attempt <= retries; attempt++) {
    try {
      const res = await fetch(url);
      if (!res.ok) throw new Error("temporary");
      return await res.json();
    } catch (error) {
      if (attempt === retries) throw error;
      const delay = 250 * Math.pow(2, attempt);
      await new Promise(r => setTimeout(r, delay));
    }
  }
}

Common errors to watch

Back to AI hub