TY - BOOK AU - MARIJN HAVERBEKE TI - ELOQUENT JAVASCRPT SN - 1393272821 AV - QA76.73 J39 H38 2019 PY - 2019/// CY - HAVERBEKE PB - UNITED STATES OF AMERICA KW - PROGRAMACION N1 - Título del libro Libro Eloquent Javascript, 3ra Edition En Ingles Autor Haverbeke, Marijn Editorial del libro No Starch Press Tapa del libro Blanda Marca No Starch Press Modelo 1593279507 Otros Cantidad de páginas 472 Tipo de narración Novela ISBN 9781593279509 ; i Contents Introduction On programming . . . . . Why language matters . . What is JavaScript? . . . . Code, and what to do with Overview of this book . . . Typographic conventions . 1 . . . . . . it . . . . . . . . . . . . . . . . . . . . . . . . . . . . Values, Types, and Operators Values . . . . . . . . . . . . . . . . . . Numbers . . . . . . . . . . . . . . . . Strings . . . . . . . . . . . . . . . . . Unary operators . . . . . . . . . . . . Boolean values . . . . . . . . . . . . . Empty values . . . . . . . . . . . . . . Automatic type conversion . . . . . . Summary . . . . . . . . . . . . . . . . 2 Program Structure Expressions and statements Bindings . . . . . . . . . . . Binding names . . . . . . . . The environment . . . . . . Functions . . . . . . . . . . . The console.log function . . Return values . . . . . . . . Control flow . . . . . . . . . Conditional execution . . . . while and do loops . . . . . . Indenting Code . . . . . . . for loops . . . . . . . . . . . Breaking Out of a Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 5 7 8 8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 10 11 13 15 15 17 18 20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 21 22 24 24 24 25 25 26 26 28 30 31 32 Updatiing bindings succinctly . . . Dispatching on a value with switch Capitalization . . . . . . . . . . . . Comments . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . 3 Functions Defining a function . . . . Bindings and scopes . . . . Nested scope . . . . . . . . Functions as values . . . . Declaration notation . . . Arrow functions . . . . . . The call stack . . . . . . . Optional Arguments . . . . Closure . . . . . . . . . . . Recursion . . . . . . . . . . Growing functions . . . . . Functions and side effects Summary . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Data Structures: Objects and Arrays The weresquirrel . . . . . . . . . . . . . . . . . . Datasets . . . . . . . . . . . . . . . . . . . . . . Properties . . . . . . . . . . . . . . . . . . . . . Methods . . . . . . . . . . . . . . . . . . . . . . Objects . . . . . . . . . . . . . . . . . . . . . . . Mutability . . . . . . . . . . . . . . . . . . . . . The lycanthrope’s log . . . . . . . . . . . . . . . Computing correlation . . . . . . . . . . . . . . Array loops . . . . . . . . . . . . . . . . . . . . . The final analysis . . . . . . . . . . . . . . . . . Further arrayology . . . . . . . . . . . . . . . . . Strings and their properties . . . . . . . . . . . Rest parameters . . . . . . . . . . . . . . . . . . The Math object . . . . . . . . . . . . . . . . . . Destructuring . . . . . . . . . . . . . . . . . . . Optional property access . . . . . . . . . . . . . iii . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 33 34 34 35 35 . . . . . . . . . . . . . . 38 38 39 40 41 42 42 43 44 45 47 50 52 53 53 . . . . . . . . . . . . . . . . 55 55 56 57 57 58 61 62 64 65 66 68 69 71 72 73 74 JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Higher-Order Functions Abstraction . . . . . . . . . . . . Abstracting repetition . . . . . Higher-order functions . . . . . Script dataset . . . . . . . . . . Filtering arrays . . . . . . . . . Transforming with map . . . . . Summarizing with reduce . . . . Composability . . . . . . . . . . Strings and character codes . . Recognizing text . . . . . . . . . Summary . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . 75 76 76 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 80 80 82 83 84 85 85 86 88 90 91 91 6 The Secret Life of Objects Abstract Data Types . . . . . . . Methods . . . . . . . . . . . . . . Prototypes . . . . . . . . . . . . . Classes . . . . . . . . . . . . . . . Private Properties . . . . . . . . . Overriding derived properties . . Maps . . . . . . . . . . . . . . . . Polymorphism . . . . . . .6 The Secret Life of Objects Abstract Data Types . . . . . . . Methods . . . . . . . . . . . . . . Prototypes . . . . . . . . . . . . . Classes . . . . . . . . . . . . . . . Private Properties . . . . . . . . . Overriding derived properties . . Maps . . . . . . . . . . . . . . . . Polymorphism . . . . . . . . . . . Getters, setters, and statics . . . Symbols . . . . . . . . . . . . . . . The iterator interface . . . . . . . Inheritance . . . . . . . . . . . . . The instanceof operator . . . . . . Summary . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 93 94 95 97 99 100 101 102 103 105 106 108 109 110 111 . . . . 112 112 114 116 116 7 Project: A Robot Meadowfield . . . . . The task . . . . . . . Persistent data . . . . Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The mail truck’s route . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Pathfinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 8 Bugs and Errors Language . . . . . . . . . . . Strict mode . . . . . . . . . . Types . . . . . . . . . . . . . Testing . . . . . . . . . . . . Debugging . . . . . . . . . . Error propagation . . . . . . Exceptions . . . . . . . . . . Cleaning up after exceptions Selective catching . . . . . . Assertions . . . . . . . . . . Summary . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 123 124 125 126 127 128 130 131 133 135 136 136 9 Regular Expressions Creating a regular expression . . . . . Testing for matches . . . . . . . . . . . Sets of characters . . . . . . . . . . . . International characters . . . . . . . . . Repeating parts of a pattern . . . . . . Grouping subexpressions . . . . . . . . Matches and groups . . . . . . . . . . . The Date class . . . . . . . . . . . . . . Boundaries and look-ahead . . . . . . . Choice patterns . . . . . . . . . . . . . The mechanics of matching . . . . . . Backtracking . . . . . . . . . . . . . . . The replace method . . . . . . . . . . . Greed . . . . . . . . . . . . . . . . . . . Dynamically creating RegExp objects The search method . . . . . . . . . . . The lastIndex property . . . . . . . . . Parsing an INI file . . . . . . . . . . . . Code units and characters . . . . . . . Summary . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Asynchronous Programming Asynchronicity . . . . . . . . . . . . . . Callbacks . . . . . . . . . . . . . . . . . Promises . . . . . . . . . . . . . . . . . Failure . . . . . . . . . . . . . . . . . . Carla . . . . . . . . . . . . . . . . . . . Breaking In . . . . . . . . . . . . . . . . Async functions . . . . . . . . . . . . . Generators . . . . . . . . . . . . . . . . A Corvid Art Project . . . . . . . . . . The event loop . . . . . . . . . . . . . . Asynchronous bugs . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Project: A Programming Language Parsing . . . . . . . . . . . . . . . . . . . . . . The evaluator . . . . . . . . . . . . . . . . . . Special forms . . . . . . . . . . . . . . . . . . . The environment . . . . . . . . . . . . . . . . Functions . . . . . . . . . . . . . . . . . . . . . Compilation . . . . . . . . . . . . . . . . . . . Cheating . . . . . . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . 13 JavaScript and the Browser Networks and the Internet . . . . . The Web . . . . . . . . . . . . . . . HTML . . . . . . . . . . . . . . . . HTML and JavaScript . . . . . . . . . . . vi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 161 162 164 165 168 169 171 171 . . . . . . . . . . . . . 173 173 175 176 178 180 181 182 184 185 188 189 191 191 . . . . . . . . 193 193 197 199 200 202 203 203 204 . . . . 206 206 208 208 211 In the sandbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Compatibility and the browser wars . . . . . . . . . . . . . . . . . . . 212 14 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 . . . . . . . . . . . . . . . . 15 Handling Events Event handlers . . . . . . . Events and DOM nodes . Event objects . . . . . . . . Propagation . . . . . . . . Default actions . . . . . . . Key events . . . . . . . . . Pointer events . . . . . . . Scroll events . . . . . . . . Focus events . . . . . . . . Load event . . . . . . . . . Events and the event loop Timers . . . . . . . . . . . Debouncing . . . . . . . . . Summary . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 214 215 216 217 218 219 220 222 222 224 226 227 228 230 230 . . . . . . . . . . . . . . . 233 233 234 235 235 237 237 239 243 244 245 245 246 247 248 249 16 Project: A Platform Game 251 The game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 The technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 vii Levels . . . . . . . . . Reading a level . . . . Actors . . . . . . . . . Drawing . . . . . . . . Motion and collision . Actor updates . . . . Tracking keys . . . . Running the game . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 253 255 258 263 266 268 269 271 17 Drawing on Canvas SVG . . . . . . . . . . . . . . . . . . . The canvas element . . . . . . . . . . Lines and surfaces . . . . . . . . . . . Paths . . . . . . . . . . . . . . . . . . Curves . . . . . . . . . . . . . . . . . Drawing a pie chart . . . . . . . . . . Text . . . . . . . . . . . . . . . . . . . Images . . . . . . . . . . . . . . . . . Transformation . . . . . . . . . . . . Storing and clearing transformations Back to the game . . . . . . . . . . . Choosing a graphics interface . . . . Summary . . . . . . . . . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 273 274 275 276 277 280 281 282 283 286 287 292 293 294 18 HTTP and Forms The protocol . . . . . Browsers and HTTP Fetch . . . . . . . . . HTTP sandboxing . . Appreciating HTTP . Security and HTTPS Form fields . . . . . . Focus . . . . . . . . . Disabled fields . . . . The form as a whole Text fields . . . . . . Checkboxes and radio Select fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 296 298 299 301 301 302 303 304 305 306 307 309 310 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii File fields . . . . . . . . Storing data client-side Summary . . . . . . . . Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .; Ingeniería en Tecnologías de la Información y Comunicación N2 - JavaScript lies at the heart of almost every modern web application, from social apps like Twitter to browser-based game frameworks like Phaser and Babylon. 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. This much anticipated and thoroughly revised third edition of Eloquent JavaScript dives deep into the JavaScript language to show you how to write beautiful, effective code. It has been updated to reflect the current state of Java¬Script and web browsers and includes brand-new material on features like class notation, arrow functions, iterators, async functions, template strings, and block scope. A host of new exercises have also been added to test your skills and keep you on track. As with previous editions, Haverbeke continues to teach through extensive examples and immerses you in code from the start, while exercises and full-chapter projects give you hands-on experience with writing your own programs. You start by learning the basic structure of the JavaScript language as well as control structures, functions, and data structures to help you write basic programs. Then you'll learn about error handling and bug fixing, modularity, and asynchronous programming before moving on to web browsers and how JavaScript is used to program them. As you build projects such as an artificial life simulation, a simple programming language, and a paint program, you'll learn how to: - Understand the essential elements of programming, including syntax, control, and data - Organize and clarify your code with object-oriented and functional programming techniques - Script the browser and make basic web applications - Use the DOM effectively to interact with browsers - Harness Node.js to build servers and utilities Isn't it time you became fluent in the language of the Web? * All source code is available online in an inter¬active sandbox, where you can edit the code, run it, and see its output instantly ER -