Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Ilya Kantor, javascript.info

Rating No ratings yet

No description

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Javascript.info Ebook Part 3: Additional Articles — Reading Guide ## 【One-Line Pitch】 A practical deep-dive into browser APIs and networking fundamentals for JavaScript developers who want to master popups, binary data, fetch, WebSocket, and security topics beyond the basics. Ideal for intermediate developers who have completed core JavaScript tutorials and now need production-ready knowledge of browser internals. ## 【Book Arc】 - **Opening (~0%–10%)**: Covers window management with `window.open`, popup positioning and feature flags, plus the Same Origin Policy — how browsers restrict access between windows and iframes from different origins. - **Early (~10%–23%)**: Explores binary data handling with typed arrays (`Int8Array`, `Uint8Array`, etc.), `ArrayBuffer` views, `TextDecoder`/`TextEncoder` for string-binary conversion, and `Blob`/`FileReader` for file operations. - **Early–Middle (~23%–39%)**: Moves into networking with `fetch` API — POST requests, `FormData` for multipart forms, `AbortController` for cancellation, and detailed `fetch` options like `cache`, `redirect`, and `credentials`. - **Middle (~39%–48%)**: Covers XMLHttpRequest upload progress tracking via `xhr.upload`, long-polling for real-time communication, and introduces WebSocket protocol with frame types and handshake details. - **Late (~48%–end)**: Discusses `EventSource` for Server-Sent Events (SSE), including reconnection behavior, message formats, and cookie security flags (`secure`, `samesite`). ## 【Key Takeaways】 - **Same Origin Policy is the security backbone** (Opening): Full access between windows/iframes only works when protocol, domain, and port match; otherwise only `location` writing (redirect) is permitted, never reading. This governs popup security and iframe embedding. - **Typed arrays have 5 constructor variants** (Early): `ArrayBuffer` views, array-like copying, typed-array conversion (with value truncation), numeric length allocation, and empty creation — each serves different use cases for binary data manipulation. - **`TextDecoder` bridges binary and strings** (Early): When binary data represents text, `TextDecoder` converts buffers to JavaScript strings with encoding support, while `TextEncoder` does the reverse — essential for file processing and network payloads. - **`URL.createObjectURL` beats FileReader for display** (Early): For showing images or triggering downloads, creating a short URL from a Blob/File is simpler and faster than reading to base64 — though FileReader remains useful for reading content as text, ArrayBuffer, or data URL. - **`AbortController` provides fetch cancellation** (Early): Create a controller, pass its `signal` to fetch, then call `abort()` — the promise rejects with `AbortError` which you must handle. Critical for user-initiated cancellations and timeouts. - **Simple vs. preflight requests in CORS** (Early): GET/POST/HEAD with limited headers are "simple" and sent directly; everything else triggers a preflight OPTIONS request. Understanding this split explains why some cross-origin requests fail mysteriously. - **`xhr.upload` tracks upload progress separately** (Middle): While `xhr.onprogress` handles downloads, `xhr.upload` fires `progress`, `load`, `error`, and related events during uploads — essential for file upload progress bars. - **Long-polling requires server architecture awareness** (Middle): The client-side `subscribe()` pattern (fetch, handle, reconnect) is simple, but servers must handle many pending connections — Node.js backends typically cope better than PHP/Ruby process-per-connection models. ## 【Reading Tips】 - **Skim the popup window feature tables** (Opening): The `window.open` parameters list is reference material — read the Same Origin Policy section carefully instead, as it's the conceptual foundation for later security topics. - **Deep-read the typed array constructor variants** (Early): This is dense but crucial — the 5 constructor behaviors (especially value truncation when converting between types) trip up many developers. Work through the code examples. - **Focus on the `fetch` options matrix** (Early–Middle): The `cache`, `redirect`, and `credentials` options each have 4–6 modes with subtle differences. Create a cheat sheet for yourself; you'll reference it constantly in real projects. - **Study the WebSocket handshake example** (Middle): The request/response pair shows exactly what headers matter (`Sec-WebSocket-Key`, `Sec-WebSocket-Accept`). Understanding the handshake demystifies why WebSocket connections sometimes fail. - **Compare long-polling vs. WebSocket vs. SSE** (Middle–Late): These three real-time techniques have different trade-offs — the book presents them sequentially, so read them together to understand when to choose each. ## 【Coverage Limits】 This guide covers the excerpted portions of Part 3, which focus on browser windows, binary data, networking (fetch, XHR, WebSocket, SSE), and cookie security. The full ebook likely includes additional articles on other topics not represented in these excerpts. ##
Page 6
no,resizable=no,status=no,location=no,toolbar=no,menubar=no width=600,height=300,left=100,top=100`; open('/', 'test', params); These ones do not: ● http://ww...
View in text
Excerpt 2
t usually URL.createObjectURL(blob) is simpler and faster. URL.createObjectURL(blob) Blob to data url ● We need to revoke them if care ● No need to revoke an...
View in text
Excerpt 3
a conditional request if there is a cached response, and a normal request otherwise. Populate HTTP-cache with the response; ● "force-cache" – use a response...
View in text
Excerpt 4
ArrayBuffer , etc. No settings required: just send it out. When we receive the data, text always comes as string. And for binary data, we can choose between...
View in text
Excerpt 5
ade is attempted. We should listen to it, so that we should close the database (and probably suggest the visitor to reload the page, to load the updated code...
View in text
Excerpt 6
e starting property value and y = 1 – the ending value. So values y<0 move the property lower than the starting left and y>1 – over the final left . That’s a...
View in text
Excerpt 7
this.attachShadow({mode: 'open'}); this.shadowRoot.innerHTML = `<div class="menu"> <slot name="title"></slot> <ul><slot name="item"></slot></ul> </div>`; //...
View in text
Excerpt 8
let regexp = /javascript/ig; regexp.lastIndex = 13; let result; while (result = regexp.exec(str)) { alert( `Found ${result[0]} at ${result.index}` ); // show...
View in text
Tags
AI categories
JavaScriptCybersecurity
Publish Year: 2019
Language: English
Pages: 318
File Format: PDF
File Size: 3.6 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…