Javascript.info Ebook Part 1 The JavaScript language (Ilya Kantor, javascript.info)(Z-Library)
JavaScript
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 1: The JavaScript Language — Reading Guide
【One-Line Pitch】
A comprehensive, browser-friendly tutorial covering JavaScript fundamentals from syntax basics to advanced object-oriented patterns — ideal for beginners starting from zero and intermediate developers wanting to fill gaps in their core language knowledge.
【Book Arc】
- **Opening (~0%–10%)**: Sets up the browser environment (DevTools, script tags) and covers absolute basics — variables, data types, type conversions, and operators. Establishes the "language-first" approach that minimizes browser-specific APIs.
- **Early (~10%–25%)**: Dives into control flow (conditionals, switch, loops), functions as building blocks, and introduces testing with BDD (Behavior-Driven Development) using Mocha/Chai. Includes a humorous "ninja code" chapter on what *not* to do.
- **Early–Middle (~25%–40%)**: Explores objects in depth — property access, `this` binding, constructor functions with `new`, object-to-primitive conversion, and numeric formats (hex, binary, octal, scientific notation). Strings and arrays get thorough treatment with practical methods.
- **Middle (~40%–50%)**: Covers advanced array methods (`reduce`, `reduceRight`), iterables vs. array-likes, `Symbol.iterator`, and introduces Map/Set/WeakMap/WeakSet collections with their garbage-collection semantics.
- **Middle (~50%+)**: Introduces destructuring assignment for arrays and objects, including default values and nested patterns — the bridge to more advanced language features covered later in the book.
【Key Takeaways】
- **Variables are simple but have strict naming rules** (Early): Only letters, digits, `$`, and `_` are allowed; camelCase is conventional. Understanding this prevents syntax errors and aligns with ecosystem style.
- **Type conversion is explicit and often necessary** (Early): `Number("123")` converts strings to numbers, but invalid strings yield `NaN`. Know the conversion table (e.g., `undefined` → `NaN`, `null` → `0`) to avoid surprises.
- **The ternary operator and switch are readability tools** (Early): `condition ? value1 : value2` replaces simple if/else; switch supports grouping cases and arbitrary expressions. Use them when they clarify intent, not as a rule.
- **Functions are the main building blocks** (Early): The book emphasizes function basics early and promises deeper coverage later. Removing unnecessary `else` after `return` is idiomatic — both variants behave identically.
- **BDD testing catches edge cases** (Early): Writing failing tests first (e.g., `pow(2, -1)` should be `NaN`) then implementing the fix is the core workflow. This is a practical skill, not just theory.
- **`this` is not bound to the object by default** (Early–Middle): Using `user.name` inside a method breaks when the variable is reassigned; `this.name` works regardless. This is a classic JavaScript gotcha worth internalizing.
- **Objects convert to primitives via a defined algorithm** (Early–Middle): The hint system (`"string"`, `"number"`, `"default"`) determines whether `toString()` or `valueOf()` is called first. Implementing `toString()` as a catch-all is often sufficient.
- **`reduce` without an initial value errors on empty arrays** (Middle): Always specify the initial value to avoid runtime errors. This is a subtle but common production bug.
【Reading Tips】
- **Skim the "ninja code" chapter** (~19%): It's humorous anti-pattern advice (bad variable names, confusing prefixes). Read it for entertainment and awareness, but don't memorize it.
- **Deep-read the object conversion section** (~29%): The `Symbol.toPrimitive` algorithm is dense but crucial for understanding how objects behave in arithmetic and string contexts. Work through the examples slowly.
- **Practice the array method tasks** (~39%–42%): The exercises (maximal subarray, sum input, array context) are excellent for internalizing `reduce`, `push`, and iteration. Do them before moving on.
- **Pay attention to WeakMap/WeakSet limitations** (~48%): No iteration, no `size`, no `clear()` — these constraints are the price for garbage-collection support. Understand *why* before using them.
- **Treat destructuring as a bridge** (~50%): Default values and nested patterns here prepare you for function parameter destructuring later. Master this now to avoid confusion in advanced chapters.
【Coverage Limits】
This guide covers the first ~50% of Part 1 (fundamentals through destructuring). Excerpts do not cover later topics like error handling, promises, async/await, classes, or modules — those appear in subsequent sections of the book.
Excerpt 1
Scala or Erlang that forbid changing variable values. In such languages, once the value is stored “in the box”, it’s there forever. If we need to store somet...
View in text
Excerpt 2
g still works, but some features behave in the old-fashion, “compatible” way. We’d generally prefer the modern behavior. Some modern features of the language...
View in text
Excerpt 3
milar objects, like multiple users or menu items and so on. That can be done using constructor functions and the "new" operator. Constructor function Constru...
View in text
Excerpt 4
actical tasks in browser or other environments, we may meet objects that are iterables or array-likes, or both. For instance, strings are both iterable ( for...
View in text
Excerpt 5
eachable, and keeps the outer lexical environment in memory Please note that if f() is called many times, and resulting functions are saved, then the corresp...
View in text
Excerpt 6
te user.name // defineProperty(user, "name", ...) Object.defineProperty(user, "name", {writable: true}); // Error Object.defineProperties There’s a method Ob...
View in text
Excerpt 7
JSON.parse(json); // <-- no errors if (!user.name) { throw new SyntaxError("Incomplete data: no name"); // (*) } alert( user.name ); } catch(e) { alert( "JSO...
View in text
Excerpt 8
Like this: fetch('/article/promise-chaining/user.json') .then(response => response.json()) .then(user => fetch(`https://api.github.com/users/${user.name}`))...
View in text
Tags
AI categories
JavaScriptProgramming LanguageWeb Technology
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…
Loading comments...
Reply to Comment
Edit Comment