Eloquent JavaScript A Modern Introduction to Programming

JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.Eloquent JavaScript, 2nd Edition...

Full description

Saved in:
Bibliographic Details
Main Author: Haverbeke, Marijn
Format: eBook
Language:English
Published: San Francisco No Starch Press, Incorporated 2014
No Starch Press
No Starch Press, Inc
Edition:2
Subjects:
ISBN:1593275846, 9781593275846
Online Access:Get full text
Tags: Add Tag
No Tags, Be the first to tag this record!
Table of Contents:
  • Passing Along Arguments -- JSON -- Filtering an Array -- Transforming with map -- Summarizing with reduce -- Composability -- The Cost -- Great-great-great-great-. . . -- Binding -- Summary -- Exercises -- Flattening -- Mother-Child Age Difference -- Historical Life Expectancy -- Every and Then Some -- Chapter 6: The Secret Life of Objects -- History -- Methods -- Prototypes -- Constructors -- Overriding Derived Properties -- Prototype Interference -- Prototype-less Objects -- Polymorphism -- Laying Out a Table -- Getters and Setters -- Inheritance -- The instanceof Operator -- Summary -- Exercises -- A Vector Type -- Another Cell -- Sequence Interface -- Chapter 7: Electronic Life -- Definition -- Representing Space -- A Critter's Programming Interface -- The World Object -- this and Its Scope -- Animating Life -- It Moves -- More Life-forms -- A More Lifelike Simulation -- Action Handlers -- Populating the New World -- Bringing the World to Life -- Exercises -- Artificial Stupidity -- Predators -- Chapter 8: Bugs and Error Handling -- Programmer Mistakes -- Strict Mode -- Testing -- Debugging -- Error Propagation -- Exceptions -- Cleaning Up After Exceptions -- Selective Catching -- Assertions -- Summary -- Exercises -- Retry -- The Locked Box -- Chapter 9: Regular Expressions -- Creating a Regular Expression -- Testing for Matches -- Matching a Set of Characters -- Repeating Parts of a Pattern -- Grouping Subexpressions -- Matches and Groups -- The Date Type -- Word and String Boundaries -- Choice Patterns -- The Mechanics of Matching -- Backtracking -- The replace Method -- Greed -- Dynamically Creating RegExp Objects -- The search Method -- The lastIndex Property -- Looping over Matches -- Parsing an INI File -- International Characters -- Summary -- Exercises -- Regexp Golf -- Quoting Style -- Numbers Again -- Chapter 10: Modules
  • Drawing a Pie Chart -- Text -- Images -- Transformation -- Storing and Clearing Transformations -- Back to the Game -- Choosing a Graphics Interface -- Summary -- Exercises -- Shapes -- The Pie Chart -- A Bouncing Ball -- Precomputed Mirroring -- Chapter 17: HTTP -- The Protocol -- Browsers and HTTP -- XMLHttpRequest -- Sending a Request -- Asynchronous Requests -- Fetching XML Data -- HTTP Sandboxing -- Abstracting Requests -- Promises -- Appreciating HTTP -- Security and HTTPS -- Summary -- Exercises -- Content Negotiation -- Waiting for Multiple Promises -- Chapter 18: Forms and Form Fields -- Fields -- Focus -- Disabled Fields -- The Form as a Whole -- Text Fields -- Checkboxes and Radio Buttons -- Select Fields -- File Fields -- Storing Data Client-Side -- Summary -- Exercises -- A JavaScript Workbench -- Autocompletion -- Conway's Game of Life -- Chapter 19: Project: A Paint Program -- Implementation -- Building the DOM -- The Foundation -- Tool Selection -- Color and Brush Size -- Saving -- Loading Image Files -- Finishing Up -- Exercises -- Rectangles -- Color Picker -- Flood Fill -- Part III: Beyond -- Chapter 20: Node.js -- Background -- Asynchronicity -- The node Command -- Modules -- Installing with NPM -- The Filesystem Module -- The HTTP Module -- Streams -- A Simple File Server -- Error Handling -- Summary -- Exercises -- Content Negotiation, Again -- Fixing a Leak -- Creating Directories -- A Public Space on the Web -- Chapter 21: Project: Skill-Sharing Website -- Design -- Long Polling -- HTTP Interface -- The Server -- Routing -- Serving Files -- Talks as Resources -- Long-Polling Support -- The Client -- HTML -- Starting up -- Displaying Talks -- Updating the Server -- Noticing Changes -- Exercises -- Disk Persistence -- Comment Field Resets -- Better Templates -- Unscriptables -- Chapter 22: JavaScript and Performance
  • Staged Compilation -- Graph Layout -- Defining a Graph -- A First Force-Directed Layout Function -- Profiling -- Function Inlining -- Going Back to Old-school Loops -- Avoiding Work -- Creating Less Garbage -- Garbage Collection -- Writing to Objects -- Dynamic Types -- Summary -- Exercises -- Pathfinding -- Timing -- Optimizing -- Exercise Hints -- Program Structure -- Looping a Triangle -- FizzBuzz -- Chess Board -- Functions -- Minimum -- Recursion -- Bean Counting -- Data Structures: Objects and Arrays -- The Sum of a Range -- Reversing an Array -- A List -- Deep Comparison -- Higher-Order Functions -- Mother-Child Age Difference -- Historical Life Expectancy -- Every and Then Some -- The Secret Life of Objects -- A Vector Type -- Another Cell -- Sequence Interface -- Project: Electronic Life -- Artificial Stupidity -- Predators -- Bugs and Error Handling -- Retry -- The Locked Box -- Regular Expressions -- Quoting Style -- Numbers Again -- Module -- Month Names -- A Return to Electronic Life -- Circular Dependencies -- Project: A Programming Language -- Arrarys -- Closure -- Comments -- Fixing Scope -- The Document Object Model -- Build a Table -- Elements by Tag Name -- Handling Events -- Censored Keyboard -- Mouse Trail -- Tabs -- Project: A Platform Game -- Game Over -- Pausing the Game -- Drawing on Canvas -- Shapes -- The Pie Chart -- A Bouncing Ball -- Precomputed Mirroring -- HTTP -- Content Negotiation -- Waiting for Multiple Promises -- Forms and Form Fields -- A JavaScript Workbench -- Autocompletion -- Conway's Game of Life -- Project: A Paint Program -- Rectangles -- Color Picker -- Flood Fill -- Node.js -- Content Negotiation, Again -- Fixing a Leak -- Creating Directories -- A Public Space on the Web -- Project: Skill-Sharing Website -- Disk Persistence -- Comment Field Resets -- Better Templates -- The Unscriptables
  • JavaScript and Performance
  • Why Modules Help -- Namespacing -- Reuse -- Decoupling -- Using Functions as NameSpaces -- Objects as Interfaces -- Detaching from the Global Scope -- Evaluating Data as Code -- The require Function -- Slow-Loading Modules -- Interface Design -- Predictability -- Composability -- Layered Interfaces -- Summary -- Exercises -- Month Names -- A Return to Electronic Life -- Circular Dependencies -- Chapter 11: Project: A Programming Language -- Parsing -- The Evaluator -- Special Forms -- The Environment -- Functions -- Compilation -- Cheating -- Exercises -- Arrays -- Closure -- Comments -- Fixing Scope -- Part II: Browser -- Chapter 12: JavaScript and the Browser -- Networks and the Internet -- The Web -- HTML -- HTML and JavaScript -- In the Sandbox -- Compatibility and the Browser Wars -- Chapter 13: The Document Object Model -- Document Structure -- Trees -- The Standard -- Moving Through the Tree -- Finding Elements -- Changing the Document -- Creating Nodes -- Attributes -- Layout -- Styling -- Cascading Styles -- Query Selectors -- Positioning and Animating -- Summary -- Exercises -- Build a Table -- Elements by Tag Name -- The Cat's Hat -- Chapter 14: Handling Events -- Event Handlers -- Events and DOM Nodes -- Event Objects -- Propagation -- Default Actions -- Key Events -- Mouse Clicks -- Mouse Motion -- Scroll Events -- Focus Events -- Load Event -- Script Execution Timeline -- Setting Timers -- Debouncing -- Summary -- Exercises -- Censored Keyboard -- Mouse Trail -- Tabs -- Chapter 15: Project: A Platform Game -- The Game -- The Technology -- Levels -- Reading a Level -- Actors -- Encapsulation as a Burden -- Drawing -- Motion and Collision -- Actors and Actions -- Tracking Keys -- Running the Game -- Exercises -- Game Over -- Pausing the Game -- Chapter 16: Drawing on Canvas -- SVG -- The Canvas Element -- Filling and Stroking -- Curves
  • Intro -- Brief Contents -- Contents in Detail -- Introduction -- On Programming -- Why Language Matters -- What Is JavaScript? -- Code, and What to Do with It -- Overview of This Book -- Typographic Conventions -- Part I: Language -- Chapter 1: Values, Types, and Operators -- Values -- Numbers -- Arithmetic -- Special Numbers -- Strings -- Unary Operators -- Boolean Values -- Comparisons -- Logical Operators -- Undefined Values -- Automatic Type Conversion -- Short-Circuiting of Logical Operators -- Summary -- Chapter 2: Program Structure -- Expressions and Statements -- Variables -- Keywords and Reserved Words -- The Environment -- Functions -- The console.log Function -- Return Values -- Prompt and Confirm -- Control Flow -- Conditional Execution -- while and do Loops -- Indenting Code -- for Loops -- Breaking Out of a Loop -- Updating Variables Succinctly -- Dispatching on a Value with switch -- Capitalization -- Comments -- Summary -- Exercises -- Looping a Triangle -- FizzBuzz -- Chess Board -- Chapter 3: Functions -- Defining a Function -- Parameters and Scopes -- Nested Scopes -- Functions as Values -- Declaration Notation -- The Call Stack -- Optional Arguments -- Closure -- Recursion -- Growing Functions -- Functions and Side Effects -- Summary -- Exercises -- Minimum -- Recursion -- Bean Counting -- Chapter 4: Data Structures: Objects and Arrays -- The Weresquirrel -- Data Sets -- Properties -- Methods -- Objects -- Mutability -- The Lycanthrope's Log -- Computing Correlation -- Objects as Maps -- The Final Analysis -- Further Arrayology -- Strings and Their Properties -- The arguments Object -- The Math Object -- The Global Object -- Summary -- Exercises -- The Sum of a Range -- Reversing an Array -- A List -- Deep Comparison -- Chapter 5: Higher-Order Functions -- Abstraction -- Abstracting Array Traversal -- Higher-Order Functions
  • Introduction -- Part 1: Language -- 1 Values, Types, and Operators -- 2 Program Structure -- 3 Functions -- 4 Data Structures: Object and Arrays -- 5 Higher-Order Functions -- 6 The Secret Life of Objects -- 7 Project: A Robot -- 8 Bugs and Errors -- 9 Regular Expressions -- 10 Modules -- 11 Asynchronous Programming -- 12 Project: A Programming Language -- Part 2: Browser -- 13 JavaScript and the Browser -- 14 The Document Object Model -- 15 Handling Events -- 16 Project: A Platform Game -- 17 Drawing on Canvas -- 18 HTTP and Forms -- 19 Project: A Pixel Art Editor -- Part 3: Node -- 20 Node.js -- 21 Project: Skill-Sharing Website -- Exercise Hints