Chapter 09 of 22 Part II: Networks and Communication

Your Invisible Digital Footprints

3 Verified Book Snippets

Every .js file below is byte-identical (SHA-256 verified) to the printed code in Volume 1. Runnable blocks execute inside an isolated sandboxed iframe and Web Worker with a 2-second timeout and zero network access.

Download Chapter ZIP

Visit (Ch. 09 Example 1)

File: block-01.js (byte-identical) · 435 bytes · SHA-256: 1a2ce02b33d6…
cookies Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Runs directly in Node.js or the isolated Web Worker sandbox and prints console output.

const shop = new Map();
let nextId = 1;

function visit(ticket, book) {
  if (!shop.has(ticket)) {
    ticket = "K" + nextId++;
    shop.set(ticket, []);
  }
  const list = shop.get(ticket);
  if (book) list.push(book);
  return { ticket, books: [...list] };
}

let first = visit(null, "Mountains");
console.log(first.books);
let again = visit(first.ticket);
console.log(again.books);
let fresh = visit(null);
console.log(fresh.books);
Download .js

Candidates (Ch. 09 Example 2)

File: block-02.js (byte-identical) · 540 bytes · SHA-256: 8958fc9f5c8d…
cookies Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Runs directly in Node.js or the isolated Web Worker sandbox and prints console output.

const visitors = [
  {id: "A", lang: "EN", screen: "wide"},
  {id: "B", lang: "EN", screen: "wide"},
  {id: "C", lang: "EN", screen: "small"},
  {id: "D", lang: "FR", screen: "wide"},
  {id: "E", lang: "FR", screen: "small"},
  {id: "F", lang: "EN", screen: "small"}
];

function candidates(clues) {
  return visitors.filter(v =>
    Object.keys(clues).every(key =>
      v[key] === clues[key]
    )
  ).map(v => v.id);
}

console.log(candidates({lang: "EN"}));
console.log(candidates({lang: "EN",
                        screen: "wide"}));
Download .js

Share Copy (Ch. 09 Example 3)

File: block-03.js (byte-identical) · 432 bytes · SHA-256: 81522fa1bf4b…
cookies Standalone runnable

Dependencies: None (standard ES2022 JavaScript). Runs directly in Node.js or the isolated Web Worker sandbox and prints console output.

const photo = {
  title: "Mountain lake",
  pixels: "DEMO_IMAGE",
  time: "2026-05-10 09:00",
  location: "Fictional park",
  camera: "Demo camera"
};

function shareCopy(original) {
  const allowed = ["title", "pixels"];
  const copy = {};
  for (const key of allowed) {
    if (Object.hasOwn(original, key)) {
      copy[key] = original[key];
    }
  }
  return copy;
}

console.log(shareCopy(photo));
console.log(photo.location);
Download .js