Language Deep Dive

JavaScript

The language of the web — and now of servers, mobile apps, desktops, and even microcontrollers. Born in 10 days, JavaScript ate the world.

Multi-paradigmDynamically TypedJIT-compiledSingle-threaded + asyncUniversal
← Back to Client Side
Quick Facts

At a Glance

Created
1995 · Netscape
Designed by
Brendan Eich
Standard
ECMAScript (ES2024)
Typing
Dynamic, weak
Runtimes
V8, SpiderMonkey, JavaScriptCore
Server runtimes
Node.js, Deno, Bun

Basic Concepts

  • Single-threaded event loop — JS uses callbacks, promises, and async/await to handle concurrency without threads.
  • First-class functions: functions are values, easily passed and returned.
  • Prototype-based objects (with class syntax sugar on top).
  • Runs everywhere: browsers, servers, mobile (React Native), desktop (Electron), edge functions.
  • The DOM is the browser's API for manipulating the page tree.
Syntax

Taste of JavaScript

// Modern JS — arrow functions, destructuring, async/await
const greet = (name) => `Hello, ${name}!`;

async function loadUsers() {
  const res  = await fetch("/api/users");
  const data = await res.json();
  return data.filter(({ active }) => active);
}

// Classes are syntactic sugar over prototypes
class Customer {
  constructor(name, age) { this.name = name; this.age = age; }
  isAdult() { return this.age >= 18; }
}
Mechanics

Key Features

The Event Loop

JavaScript runs one thing at a time. The runtime queues async work (timers, IO, promise resolutions) and the event loop pulls them onto the stack when it's idle. Block the loop and the whole app freezes — never run heavy CPU work in the main thread.

Promises & async/await

A Promise represents a value that will exist in the future. async/await is syntactic sugar that lets you write asynchronous code as if it were synchronous.

Modules

Two systems coexist: ESM (import/export, the standard) and CommonJS (require, legacy Node). Modern code uses ESM; tooling bridges the two.

Tooling Ecosystem
CategoryTools
Package managersnpm, pnpm, yarn, bun
BundlersVite, Webpack, esbuild, Rollup, Parcel
TranspilersBabel, SWC, TypeScript
TestJest, Vitest, Playwright, Cypress, Mocha
Lint / formatESLint, Prettier, Biome
Major Frameworks
Frontend

React, Vue, Angular, Svelte, Solid, Qwik.

Meta-frameworks

Next.js, Nuxt, SvelteKit, Remix, Astro.

Backend

Express, Fastify, NestJS, Hono, Koa.

Mobile / Desktop

React Native, Expo, Electron, Tauri.

Trade-offs

Strengths & Weaknesses

Strengths
  • The only language that runs natively in browsers.
  • One language across client, server, mobile, edge.
  • Largest package ecosystem on earth (npm).
  • Async-first, lightweight, fast iteration.
Weaknesses
  • Quirks & coercion ("0" == false) bite beginners.
  • Dynamic typing → most teams adopt TypeScript.
  • Tooling churn — frameworks rise & fall fast.
  • Single-threaded; CPU-heavy work needs workers.
Where It Shines

Sweet Spots

Web Frontends

The default — SPA, SSR, static, edge.

Real-time Backends

Chat, dashboards, websockets — Node.js excels.

Cross-Platform Mobile

React Native shares code with web teams.

Edge Functions

Cloudflare Workers, Vercel Edge — JS at the edge of the network.

Continue

Other Languages