Introduction & Learning Goals

🎯 What You'll Learn

🌐 HTTP Protocol
  • Client-server architecture
  • Request/response cycle
  • Status codes & headers
⚑ JavaScript Core
  • Functions, objects & arrays
  • Async: Promises & async/await
  • Modern ES6+ syntax
πŸ–₯️ Browser APIs
  • DOM manipulation
  • Events & event handling
  • Fetch API & AJAX
πŸš€ Node.js
  • Server-side JavaScript
  • File system & modules
  • Building APIs
πŸ“š Course Flow
HTTP Basics β†’ JS Refresher β†’ Browser β†’ Node.js
  • Understand how the web works: clients, servers, and HTTP.
  • Refresh core JavaScript concepts and modern patterns.
  • Apply JavaScript in the browser (DOM) and on the server (Node.js).

Web Foundations: HTTP

πŸ‘₯ Understanding the Actors

Every HTTP request involves a client and a server

πŸ”„ Roles per request

A client starts a request; a server answers. In chains (your server β†’ external API) the roles switch per hop.

Why ports

One IP, many apps. The OS delivers packets to the process bound to the destination port.

DNS β†’ IP

Resolve example.com to an IP (cached by TTL). CDNs often answer with a nearby edge.

Connect, then HTTP

TCP 3‑way β†’ TLS (for HTTPS) β†’ send request line + headers β†’ receive response.

Advanced: routing & sockets
πŸ”€
Reverse proxy routing
443 (Nginx) can route api.example.com β†’ localhost:8000, www.example.com β†’ localhost:3000, assets β†’ localhost:9000.
πŸ”Œ
Ephemeral client ports
Each connection is a 4‑tuple (clientIP:clientPort ⇄ serverIP:serverPort), e.g. 198.51.100.24:53214 ⇄ 203.0.113.10:443.
🌍
Anycast/CDN
One advertised IP maps to multiple edges; DNS and BGP steer you to a close POP.

Anatomy of HTTP Messages

A message = start line + headers + optional body. Each part has distinct semantics. Dive deeper for framing, wire format, and caching implications.

Status Codes: Semantics & Strategy

Status codes drive caching, retries, SEO, monitoring and auth flows before any body is read. Use precise codes consistently; guesswork costs performance.

Headers & Content Types (Quick View)

Headers = metadata; start line + headers often decide caching, routing, auth before body is read. Content type tells parsers how to treat the body.

🀝
NEGOTIATION
Accept
Content-Type
πŸ’Ύ
CACHING
Cache-Control
ETag
validators
πŸ”
AUTH
Authorization
WWW-Authenticate
πŸͺ
SESSION
Cookie
Set-Cookie
πŸ—œοΈ
COMPRESSION
Accept-Encoding
Content-Encoding
πŸ”
TRACE
Traceparent
X-Request-ID
πŸ“„
REPRESENTATION
JSON
HTML
multipart
binary

Communication Examples

GET Request

A simple GET request to fetch a list of users. The client specifies it accepts JSON responses.

GET /api/users HTTP/1.1
Host: example.com
Accept: application/json

POST Request

A POST request to create a new user. The body contains JSON data with the user's information.

POST /api/users HTTP/1.1
Host: example.com
Content-Type: application/json

{"name":"Mehdi","role":"student"}

Server Response

A successful response with caching headers, compression, and an ETag for future revalidation.

HTTP/1.1 200 OK
Date: Thu, 06 Nov 2025 10:11:12 GMT
Server: example-app
Content-Type: application/json; charset=utf-8
Cache-Control: max-age=60, public
ETag: "users:v1:af31b2"
X-Request-ID: 8b7c2f55-91d7-4e6a-8209-9f8a1f4c1c21
Content-Encoding: br

[{"id":1,"name":"Mehdi"},{"id":2,"name":"Ada"}]

Reading the response without the body: Status + headers already tell success, cacheability, compression, and revalidation strategy (ETag). Monitoring often ignores the body.

JavaScript Overview

βš™οΈ How JavaScript Works

πŸ“
Your Code
.js files
β†’
πŸ”§
JS Engine
V8, SpiderMonkey
β†’
⚑
Execution
Machine code
Single-Threaded
One task at a time
Event Loop
Handles async operations
ECMAScript
Language standard
Non-Blocking
Async I/O operations

Engines & the Language

JS engines (like V8, SpiderMonkey) implement the ECMAScript standard. JS is single‑threaded with an event loop; asynchronous work uses callbacks, promises, and async/await.

Core Concepts at a Glance

πŸ“¦

Types & Variables

Primitives, type coercion, let/const, functions & arrow functions

string number boolean () =>
πŸ—οΈ

Objects & Context

Object literals, prototypes, this binding, classes & constructor patterns

this bind class new
πŸ“Š

Arrays & Iteration

Functional array methods, higher-order functions, transformations & reductions

map filter reduce sort
⚑

Errors & Async

Exception handling, promises, async/await, error propagation patterns

try/catch Promise async await

Deep dive in the Language Refresher.

Node.js Runtime

πŸš€ Node.js Architecture

πŸ“ Your JavaScript Code
↓
πŸ”§ Node.js APIs
fs, http, path, crypto...
↓
V8 Engine
JS execution
libuv
Async I/O
↓
πŸ’» Operating System
Files, Network, Processes
Common Use Cases:
🌐 REST APIs ⚑ Real-time apps πŸ’» CLI tools πŸ”— Microservices

Idea behind Node.js

Node.js runs JavaScript on the server using the V8 engine plus system bindings for files, network, and more. It’s great for I/O‑heavy apps.

Learn more

See the dedicated Node.js page for examples and patterns.

πŸš€ Ready to go deeper?

Continue to JavaScript Refresher

Strengthen your JavaScript fundamentals with modern ES6+ syntax, functions, objects, and async patterns.

πŸ“¦ Variables & Types
⚑ Functions & Objects
πŸ”„ Async & Promises
Explore JS Refresher
{ }
</>
DOM
? Shortcuts

⌨️ Keyboard Shortcuts

Next section J
Previous section K
Change language L
Toggle theme T
Scroll to top Home
Close modal Esc