Eloquent JavaScript. 4 Ed

Eloquent JavaScript. 4 Ed

Eloquent JavaScript. 4 Ed
Автор: Haverbeke Marijn
Дата выхода: 2024
Издательство: No Starch Press, Inc.
Количество страниц: 434
Размер файла: 1,8 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

JavaScript Book - Table of Contents

Introduction

  • Introduction 1
  • On programming 2
  • Why language matters 3
  • What is JavaScript? 5
  • Code, and what to do with it 7
  • Overview of this book 8
  • Typographic conventions 8

Chapter 1: Values, Types, and Operators (Page 10)

  • Values 10
  • Numbers 11
  • Strings 13
  • Unary operators 15
  • Boolean values 15
  • Empty values 17
  • Automatic type conversion 18
  • Summary 20

Chapter 2: Program Structure (Page 21)

  • Expressions and statements 21
  • Bindings 22
  • Binding names 24
  • The environment 24
  • Functions 24
  • The console.log function 25
  • Return values 25
  • Control flow 26
  • Conditional execution 26
  • while and do loops 28
  • Indenting Code 30
  • for loops 31
  • Breaking Out of a Loop 32
  • Updating bindings succinctly 32
  • Dispatching on a value with switch 33
  • Capitalization 34
  • Comments 34
  • Summary 35
  • Exercises 35

Chapter 3: Functions (Page 38)

  • Defining a function 38
  • Bindings and scopes 39
  • Nested scope 40
  • Functions as values 41
  • Declaration notation 42
  • Arrow functions 42
  • The call stack 43
  • Optional Arguments 44
  • Closure 45
  • Recursion 47
  • Growing functions 50
  • Functions and side effects 52
  • Summary 53
  • Exercises 53

Chapter 4: Data Structures: Objects and Arrays (Page 55)

  • The weresquirrel 55
  • Data sets 56
  • Properties 57
  • Methods 57
  • Objects 58
  • Mutability 61
  • The lycanthrope's log 62
  • Computing correlation 64
  • Array loops 65
  • The final analysis 66
  • Further arrayology 68
  • Strings and their properties 69
  • Rest parameters 71
  • The Math object 72
  • Destructuring 73
  • Optional property access 74
  • JSON 75
  • Summary 76
  • Exercises 76

Chapter 5: Higher-Order Functions (Page 79)

  • Abstraction 80
  • Abstracting repetition 80
  • Higher-order functions 82
  • Script data set 83
  • Filtering arrays 84
  • Transforming with map 85
  • Summarizing with reduce 85
  • Composability 86
  • Strings and character codes 88
  • Recognizing text 90
  • Summary 91
  • Exercises 91

Chapter 6: The Secret Life of Objects (Page 93)

  • Abstract Data Types 93
  • Methods 94
  • Prototypes 95
  • Classes 96
  • Private Properties 99
  • Overriding derived properties 99
  • Maps 101
  • Polymorphism 102
  • Getters, setters, and statics 103
  • Symbols 104
  • The iterator interface 106
  • Inheritance 108
  • The instanceof operator 109
  • Summary 110
  • Exercises 110

Chapter 7: Project: A Robot (Page 112)

  • Meadowfield 112
  • The task 114
  • Persistent data 116
  • Simulation 116
  • The mail truck's route 118
  • Pathfinding 119
  • Exercises 121

Chapter 8: Bugs and Errors (Page 123)

  • Language 123
  • Strict mode 124
  • Types 125
  • Testing 126
  • Debugging 127
  • Error propagation 128
  • Exceptions 130
  • Cleaning up after exceptions 131
  • Selective catching 133
  • Assertions 135
  • Summary 136
  • Exercises 136

Chapter 9: Regular Expressions (Page 138)

  • Creating a regular expression 138
  • Testing for matches 139
  • Sets of characters 139
  • International characters 140
  • Repeating parts of a pattern 142
  • Grouping subexpressions 143
  • Matches and groups 143
  • The Date class 144
  • Boundaries and look-ahead 145
  • Choice patterns 146
  • The mechanics of matching 147
  • Backtracking 147
  • The replace method 149
  • Greed 150
  • Dynamically creating RegExp objects 152
  • The search method 152
  • The lastIndex property 153
  • Parsing an INI file 154
  • Code units and characters 157
  • Summary 157
  • Exercises 159

Chapter 10: Modules (Page 161)

  • Modular programs 161
  • ES modules 162
  • Packages 163
  • CommonJS modules 165
  • Building and bundling 168
  • Module design 169
  • Summary 171
  • Exercises 171

Chapter 11: Asynchronous Programming (Page 173)

  • Asynchronicity 173
  • Callbacks 175
  • Promises 176
  • Failure 178
  • Carla 180
  • Breaking In 181
  • Async functions 182
  • Generators 184
  • A Corvid Art Project 185
  • The event loop 188
  • Asynchronous bugs 189
  • Summary 191
  • Exercises 191

Chapter 12: Project: A Programming Language (Page 193)

  • Parsing 193
  • The evaluator 197
  • Special forms 199
  • The environment 200
  • Functions 202
  • Compilation 203
  • Cheating 203
  • Exercises 204

Chapter 13: JavaScript and the Browser (Page 206)

  • Networks and the Internet 206
  • The Web 208
  • HTML 208
  • HTML and JavaScript 211
  • In the sandbox 212
  • Compatibility and the browser wars 212

Chapter 14: The Document Object Model (Page 214)

  • Document structure 214
  • Trees 215
  • The standard 216
  • Moving through the tree 217
  • Finding elements 218
  • Changing the document 219
  • Creating nodes 220
  • Attributes 222
  • Layout 222
  • Styling 224
  • Cascading styles 226
  • Query selectors 227
  • Positioning and animating 228
  • Summary 230
  • Exercises 230

Chapter 15: Handling Events (Page 233)

  • Event handlers 233
  • Events and DOM nodes 234
  • Event objects 235
  • Propagation 235
  • Default actions 237
  • Key events 237
  • Pointer events 239
  • Scroll events 243
  • Focus events 244
  • Load event 245
  • Events and the event loop 245
  • Timers 246
  • Debouncing 247
  • Summary 248
  • Exercises 249

Chapter 16: Project: A Platform Game (Page 251)

  • The game 251
  • The technology 252
  • Levels 252
  • Reading a level 253
  • Actors 255
  • Drawing 258
  • Motion and collision 263
  • Actor updates 266
  • Tracking keys 268
  • Running the game 269
  • Exercises 271

Chapter 17: Drawing on Canvas (Page 273)

  • SVG 273
  • The canvas element 274
  • Lines and surfaces 275
  • Paths 276
  • Curves 277
  • Drawing a pie chart 280
  • Text 281
  • Images 282
  • Transformation 283
  • Storing and clearing transformations 286
  • Back to the game 287
  • Choosing a graphics interface 292
  • Summary 293
  • Exercises 294

Chapter 18: HTTP and Forms (Page 296)

  • The protocol 296
  • Browsers and HTTP 298
  • Fetch 299
  • HTTP sandboxing 301
  • Appreciating HTTP 301
  • Security and HTTPS 302
  • Form fields 303
  • Focus 304
  • Disabled fields 305
  • The form as a whole 306
  • Text fields 307
  • Checkboxes and radio buttons 308
  • Select fields 309
  • File fields 311
  • Storing data client-side 312
  • Summary 314
  • Exercises 315

Chapter 19: Project: A Pixel Art Editor (Page 317)

  • Components 317
  • The state 319
  • DOM building 320
  • The canvas 321
  • The application 324
  • Drawing tools 326
  • Saving and loading 329
  • Undo history 331
  • Let's draw 333
  • Why is this so hard? 334
  • Exercises 335

Chapter 20: Node.js (Page 337)

  • Background 337
  • The node command 338
  • Modules 339
  • Installing with NPM 340
  • The file system module 342
  • The HTTP module 343
  • Streams 345
  • A file server 346
  • Summary 351
  • Exercises 352

Chapter 21: Project: Skill-Sharing Website (Page 354)

  • Design 354
  • Long polling 355
  • HTTP interface 356
  • The server 358
  • The client 365
  • Exercises 371

Exercise Hints (Page 373)

  • Program Structure 373
  • Functions 374
  • Data Structures: Objects and Arrays 375
  • Higher-Order Functions 377
  • The Secret Life of Objects 378
  • Project: A Robot 379
  • Bugs and Errors 380
  • Regular Expressions 380
  • Modules 381
  • Asynchronous Programming 382
  • Project: A Programming Language 384
  • The Document Object Model 385
  • Handling Events 386
  • Project: A Platform Game 387
  • Drawing on Canvas 388
  • HTTP and Forms 390
  • Project: A Pixel Art Editor 391
  • Node.js 393
  • Project: Skill-Sharing Website 394

JavaScript, the programming language that allows us to add programs to web pages, lies at the heart of almost every modern web application, from social media sites to browser-based games. Just about every device can run it, making it a great choice for writing universally useful code.
The fourth edition of this classic textbook takes you on a journey through the language of the web, starting from its basic elements and building up to engaging, complete programs. The author’s personal experiences from years of maintaining popular open source projects enliven the text with practical insights and examples.
This edition of Eloquent JavaScript updates the book to describe the 2024 version of JavaScript, and shifts the attention given to some topics to better reflect current development practices.
The text takes a practical approach to teaching, rooting theory in plenty of motivating examples. The first half of the book describes the fundamentals of the language, whereas the second half shows how to apply it in two programming environments: the web browser and Node.js. Five project chapters show how to build bigger programs, working through these projects in a piecemeal, conversational way. They include a pathfinding robot, a small programming language, a platform game, a pixel drawing program, and a simple dynamic website.
Exercises provided at the end of most chapters will challenge you to creatively apply the concepts and techniques introduced. The book’s companion website provides an interactive environment for working on these exercises and playing with the example programs.
Whether you’re looking to learn JavaScript or to deepen your programming skills, you’ll find this book full of stimulating material.
Updated to ECMAScript 2024


Похожее:

Список отзывов:

Нет отзывов к книге.