What you will learn in Secrets of the JavaScript Ninja, Second Edition
Chapter by chapter
Chapter 1: Chapter 1. JavaScript is everywhere
The chapter introduction uses two developers’ experiences to show why JavaScript skills transfer across application domains and why the language has spread beyond web pages.
What you learn in chapter 1 →Chapter 2: Chapter 2. Building the page at runtime
The introduction places JavaScript in the browser-based lifecycle of a client-side web application and identifies the basic roles of HTML, JavaScript, events, the DOM, and the event loop.
What you learn in chapter 2 →Chapter 3: Chapter 3. First-class functions for the novice: definitions and arguments
The introduction explains why functions are central to JavaScript and establishes that they are first-class objects.
What you learn in chapter 3 →Chapter 4: Chapter 4. Functions for the journeyman: understanding function invocation
Introduces the implicit function parameters `this` and `arguments` and explains that how a function is invoked influences their values.
What you learn in chapter 4 →Chapter 5: Chapter 5. Functions for the master: closures and scopes
The introduction explains why closures matter in JavaScript and links their existence to the way JavaScript scopes work.
What you learn in chapter 5 →Chapter 6: Chapter 6. Functions for the future: generators and promises
Introduces generators and promises as ES6 features, explaining their basic roles before the chapter explores how to use them.
What you learn in chapter 6 →Chapter 7: Chapter 7. Object orientation with prototypes
Introduces prototypes as the basis for JavaScript’s approach to object-oriented code.
What you learn in chapter 7 →Chapter 8: Chapter 8. Controlling access to objects
The introduction explains why changing JavaScript objects may need monitoring and identifies getters, setters, and proxies as ways to control access.
What you learn in chapter 8 →Chapter 9: Chapter 9. Dealing with collections
Introduces arrays, maps, and sets by identifying the basic role of each collection.
What you learn in chapter 9 →Chapter 10: Chapter 10. Wrangling regular expressions
The chapter introduction explains why regular expressions are valuable for concise string processing in JavaScript and identifies common uses.
What you learn in chapter 10 →Chapter 11: Chapter 11. Code modularization techniques
The introduction explains why growing JavaScript applications benefit from modules and why developers used modularization techniques before ES6 introduced native modules.
What you learn in chapter 11 →Chapter 12: Chapter 12. Working the DOM
The introduction explains why DOM modification matters for dynamic web applications and why understanding it can improve performance even when using a library.
What you learn in chapter 12 →Chapter 13: Chapter 13. Surviving events
The chapter introduction recalls a simplified event-loop model and defines timers as asynchronous delays before previewing the chapter’s topics.
What you learn in chapter 13 →Chapter 14: Chapter 14. Developing cross-browser strategies
The introduction frames cross-browser JavaScript development as a broad challenge that requires prioritizing limited project resources.
What you learn in chapter 14 →Concepts explained in this book
- generatorA JavaScript function that can yield values, suspend execution, and later resume with its local state preserved.
- thisThe implicit JavaScript function binding whose value is determined by how the function is called.
- callbackA function supplied to other code to be invoked later when a condition or event occurs.
- closureA function together with the lexical environment in which it was created, allowing it to access variables from that environment after the outer function has finished executing.
- promiseA JavaScript object representing the eventual completion or failure of an asynchronous operation and its resulting value.
- event queueA queue that holds pending events for later processing.
- lexical environmentAn internal JavaScript structure that holds identifier bindings and links to an outer environment for name resolution.
- private variableA variable intended to be inaccessible from outside an abstraction boundary, such as an object or function scope.
- immediately invoked function expressionA function expression that is defined and invoked immediately in the same syntactic construct.
- regular expressionA pattern for matching character sequences in text.
- event loopA runtime scheduling mechanism that coordinates when queued events and callbacks are handled by an application.
- Object.definePropertyA JavaScript method that defines or modifies a property on an object with explicit control over its attributes.
- execution contextAn internal JavaScript runtime record that tracks the code being evaluated and the environment used to resolve identifiers.
- function declarationA JavaScript statement that defines a named function.
- moduleA bounded unit of code used to organize and reuse program functionality.
- getterA pair of property accessors that execute custom code when a property is read or assigned.
- constructor functionA function intended to create and initialize an object when invoked with new.
- forEachAn Array method that invokes a callback once for each array element.
- module patternA design pattern that encapsulates private implementation details behind a public interface, typically by returning an object from a closure or immediate function.
- microtaskA unit of deferred work processed after the current task and before the event loop proceeds to another task.
- nextAn iterator method that advances iteration and returns the next result; for a generator, it can also pass a value into the suspended computation.
- scopeThe region in which an identifier's binding is visible and can be resolved.
- yieldAn expression in a JavaScript generator that yields a value and evaluates to a value supplied when execution resumes.
- setterA property accessor function called when a value is assigned to the property.
- event bubblingThe phase of event dispatch in which an event travels from its target up through the DOM hierarchy.
- instanceof operatorA JavaScript operator that tests whether an object was created by, or inherits from, a particular constructor via its prototype chain.
- cross-browser developmentCross-browser development is the practice of writing web code that works acceptably across multiple browsers despite differences in support and behavior.
- macrotaskAn event-loop task such as an event handler or timer callback, processed separately from microtasks.
- prototypeAn object from which another object can inherit properties in JavaScript.
- arrow functionA concise JavaScript function syntax that captures this lexically from its creation context rather than creating its own binding.
- sorting algorithmAn Array method that sorts an array in place using a comparison function or default ordering.
- inheritanceA reuse relationship in which one object or type can access properties or behavior defined by another through a hierarchical relationship.
- new keywordA JavaScript operator that creates an object instance and invokes a constructor function with that object as its this value.
- taskA unit of scheduled work processed by a runtime's event loop, such as an event handler or timer callback.
- first-class objectA value that can be assigned, passed as an argument, returned, and otherwise handled like an ordinary value.
- AMDA JavaScript module format designed to support asynchronous module loading and dependency resolution, especially in browsers.
- CommonJSA JavaScript module system that defines reusable modules with synchronous loading, commonly used in Node.js.
- event capturingThe phase of DOM event dispatch in which an event travels down the hierarchy toward its target.
- Array.prototype.filterAn Array method that creates a new array containing elements that pass a callback test.
- custom eventA programmer-defined event that represents an application-specific occurrence and can be triggered and handled like a built-in event.
- regex groupingA regular-expression subgroup whose matched text is recorded for later access or reference.
- character classA regular expression construct in square brackets that matches one character from a specified set or range, optionally negated.
- event delegationAn event-handling pattern in which a parent or ancestor element handles events for descendant elements by relying on propagation.
- single-threaded execution modelAn execution model in which only one unit of code runs at a time within a given execution context.
- allAn Array method that returns true if every element passes a callback test.
- findAn Array method that returns the first element passing a callback test, or undefined if none does.
- mapAn Array method that creates a new array by applying a callback to each element.
- reduction operationAn Array method that applies a callback across elements to accumulate a single result.
- anyAn Array method that returns true if at least one element passes a callback test.
- MapA collection type that stores key-value associations and supports efficient lookup by key.
- function expressionA function defined as an expression rather than a declaration, producing a function value that can be assigned or passed around.
- feature detectionChecking whether a runtime environment supports a capability by testing for the feature itself.
- prototype chainThe linked sequence of prototype objects consulted during inherited property lookup.
- DOM clobberingBrowser behavior in which form controls named by their id or name create or replace properties on their containing form element.
- argumentsAn array-like object available inside non-arrow JavaScript functions that exposes the arguments passed to the current invocation.
- iteratorAn object that produces a sequence of values one at a time through an iteration protocol, typically using a next method.
- applyA JavaScript Function method that invokes a function with an explicit this value and arguments supplied as an array-like object.
- callA JavaScript Function method that invokes a function with an explicit this value and arguments supplied individually.
- identifier resolutionThe process of determining which binding a given identifier refers to in a particular program context.
- constructor propertyA property that references a constructor function associated with an object or prototype.
- async functionA JavaScript function marked as asynchronous that can use await and returns a promise.
- apiThe public set of functions and properties through which a module exposes its capabilities.
- event handlingThe phase of a web application's lifecycle in which the program waits for events and invokes event handlers.
- rest operatorA function parameter syntax that collects remaining supplied arguments into a single array-like value.
- import statementJavaScript module syntax for bringing exported bindings from another module into the current module's scope.
- exportA JavaScript module keyword that makes bindings available for import by other modules.
- asynchronous programmingProgram code structured to handle operations that may complete after control has returned to the caller.
- setIntervalA timer function that repeatedly schedules a callback at a specified interval until canceled.
- setTimeoutA timer function that schedules a callback to run after a specified delay.
- timer delayThe minimum elapsed time requested before a timer's corresponding task is added to the task queue, not a guarantee of when it executes.
- event propagationEvent propagation is the movement of an event through the DOM hierarchy from its target toward or from ancestor elements.
- quantifierA regular-expression operator that specifies how many times a preceding term may occur.
- offsetHeightA DOM element property reporting its layout height in pixels, including padding and borders.
- style propertyA DOM element property that exposes its inline style declarations as a mutable CSSStyleDeclaration object.
- logThe practice of recording useful runtime information to help understand program behavior or diagnose problems.
- classJavaScript syntax introduced in ES6 for defining classes, including constructor behavior, methods, and inheritance over the prototype system.
- global codeJavaScript source text that is not enclosed in a function and is evaluated in the global execution context.
- property descriptorAn object that specifies the attributes and accessors used to define or control a JavaScript property.
- ProxyA JavaScript object that intercepts operations on a target object using a handler.
- constructor return valueThe value produced by a constructor call, where an explicitly returned object replaces the newly created instance and a nonobject return is ignored.
- default exportThe binding or value designated as a module's default export, which can be imported under a chosen local name.
- default parameterA function parameter with a default value used when the caller omits an argument or passes undefined.
- JavaScriptA high-level, dynamically typed programming language standardized as ECMAScript and commonly used for web, server-side, desktop, mobile, and other application development.
- HTML stringA text representation of HTML markup that can be parsed into a document structure.
- execution context stackA stack-like runtime structure that records active execution contexts for nested calls and returns.
- offsetWidthA DOM element property reporting its layout width in pixels, including padding and borders.
- trapA Proxy handler function that intercepts a particular operation on the target object.
- alternationA regular-expression construct that matches one of several alternative subpatterns.
- const qualifierA JavaScript binding declared with const that must be initialized at declaration and cannot be reassigned, although an object or array it references can still be modified.
- dependencyA module or component that another module requires in order to function correctly.
- decouplingA design property in which interacting components know little or nothing about one another's internal details or control flow.
- strict modeA JavaScript mode that applies stricter parsing and runtime semantics.
- eventA detectable occurrence, such as a user action or timer firing, to which a program can respond.
- hoistingA common description of JavaScript declaration handling as moving declarations to the top of a scope, although declarations are registered before code executes rather than literally moved.
- identifier registrationThe pre-execution process of recording declared identifiers and their initial bindings in a lexical environment.
- syntactic sugarLanguage syntax that makes an operation easier to read or write without adding new underlying capabilities.
- backreferenceA reference that reuses text previously matched by a capturing group.
- finite-state machineA model of a system as a set of states and transitions between those states.
- replace methodA JavaScript String method that returns a new string with matched text replaced by specified text or text produced by a callback.
- timerA host-environment scheduling mechanism for running code after a delay or at repeated intervals.
- getComputedStyleA browser method that returns the computed CSS values for an element after cascading and inheritance are applied.
- function codeJavaScript source text contained within a function body and executed when the function is called.
- browser bugAn error in a browser implementation that causes behavior to differ from what is expected.
- setA JavaScript collection of unique values.
- callThe act of executing a function through a function invocation mechanism.
- instance variableA property that belongs directly to a particular object instance rather than being inherited from its prototype.
- for...ofA JavaScript loop that iterates over iterable values using the iterator protocol.
- innerHTMLA DOM element property that gets or sets HTML markup as the serialized contents of an element.
- layout thrashingA performance problem in browser rendering that happens when repeated DOM reads and writes force frequent synchronous layout recalculations.
- computed propertyA property whose value is derived on access or assignment rather than stored as an independent data field.
- named exportAn exported module binding identified by its declared or explicitly assigned name, allowing a module to expose multiple bindings.
- global objectThe object that serves as the default top-level namespace and container for globally accessible bindings in a JavaScript environment.
- windowThe browser-provided global object representing a browsing context and exposing browser APIs.
- fulfilled stateThe promise state indicating successful completion with a value.
- pending stateThe promise state in which the final outcome has not yet been determined.
- rejected stateThe promise state indicating unsuccessful completion with a rejection reason.
- handlerA callable routine that runs in response to a dispatched event.
- microtask queueA queue that holds microtasks to be processed between event-loop tasks.
- function execution contextAn execution context created for evaluating a particular function invocation in JavaScript.
- global execution contextThe global execution context and its associated object value, which can serve as this in non-strict function calls without an explicit receiver.
- error handlingThe practice of detecting and responding to errors that occur during program execution.
- arguments aliasingThe non-strict-mode behavior in which indexed values of the arguments object and corresponding function parameters share changes.
- get/set trapA collective term for Proxy traps that intercept property reads and writes.
- browser rendering pipelineThe browser process of producing or updating a web page’s visual presentation from its document and styles.
- function parameterA variable listed in a function definition that receives a corresponding argument when the function is invoked.
- [[Environment]]The internal function property that stores a reference to the lexical environment in which the function was created.
- attributeA named association on an object that holds a value or provides accessor behavior.
- non-blocking callAn operation arranged so that its work does not block the program’s execution while it is being performed.
- DOM fragmentA lightweight, detached portion of a DOM tree that can be manipulated separately before being inserted into a document.
- macrotask queueA queue that holds pending tasks for processing by an event loop.
- event targetThe object or element on which an event originally occurred and which is exposed through the event object's target reference.
- negative indexingAn indexing convention that allows arrays to be accessed from the end using negative positions.
- pushAn Array method that appends one or more elements and returns the new length.
- regular expression literalJavaScript source syntax that specifies a regular-expression pattern between slash delimiters, optionally followed by flags.
- html wrappingThe technique of surrounding HTML markup with required container markup before parsing or insertion.
- function scopeA scope in which a variable is visible throughout the entire function body rather than being limited to a block.
- computed styleThe set of CSS property values resolved for an element after the browser accounts for applicable browser defaults, style sheets, inline declarations, inheritance, and script changes.
- getPropertyValueA CSSStyleDeclaration method that retrieves the computed value of a specified CSS property.
- memoizationA technique that stores computed results so repeated calls with the same inputs can reuse them.
- arrayAn ordered, indexed collection of values.
- polyfillA polyfill is code that implements a feature in environments that do not natively support it, emulating the missing behavior.
- async/awaitA language keyword that pauses an async function until a promise settles and then evaluates to the promise's result or throws its rejection.
- code compilationThe process of translating a program or expression into an internal form suitable for execution.
- regressionA failure of previously working software behavior following a change.
- Promise.allA JavaScript Promise combinator that returns a promise fulfilled when all input promises fulfill, or rejected if any input promise rejects.
- then methodA Promise method that registers fulfillment and rejection handlers and returns a new promise for chaining.
- event-handler registrationThe act of associating a handler with an event target or event type so it runs when the event occurs.
- prototype-based object orientationAn object-oriented model in which objects inherit properties through prototype links rather than class inheritance.
- dropdownAn HTML element that provides a control for selecting among options.
- noncapturing groupA regular-expression group that combines subpatterns without recording their matched text as a capture.
- array methodA method available on arrays for operations such as iteration, transformation, or querying.
- camel caseA naming convention in which words are joined without spaces and each word after the first begins with a capital letter.
- page buildingThe phase of a web application's lifecycle in which the user interface is set up before event handling begins.
- safe cross-browser fixA cross-browser fix that resolves a browser-specific problem without adverse effects in other browsers or reliance on detection logic.
- accessor methodA method used to retrieve or update a property or encapsulated state.
- addEventListenerA DOM method for registering an event listener on an event target without replacing existing listeners for the same event type.
- lambdaA function that has no name.
- debuggingThe process of finding, inspecting, and correcting software defects or unexpected behavior.
- set unionA set operation that produces a set containing every element present in either operand set.
- executor functionThe function passed to a Promise constructor that runs immediately and receives resolve and reject callbacks.
- exec methodA RegExp method in JavaScript that executes a pattern search and returns the next match result, including captures when available.
- global regular expressionA regular expression with the g flag, enabling successive searches for matches in a string.
- match methodA JavaScript method that searches a string with a regular expression and returns match information.
- set intersectionA set operation that produces a set containing the elements common to the operand sets.
- set differenceThe set of elements in one set that are not in another set.
- identifierA name used to identify an entity in a program.
- exportsA CommonJS variable that initially references a module's export object and can be used to define exported members.
- module.exportsThe CommonJS property whose assigned value is exposed as a module's public API.
- requireA CommonJS function that loads a module and returns its exported interface.
- external codeCode outside a component or library that coexists in the same page or environment and may affect or be affected by it.
- cross-browser development concernAn issue that affects code across browsers, such as implementation bugs, regressions, interference, or absent features.
- script elementAn HTML element whose content or referenced resource contains executable script code.
- metacharacterA character in a regular expression that has a syntactic meaning rather than being matched literally.
- variable declaration keywordA JavaScript keyword used to declare a variable binding, such as var, let, or const.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
