PDF Google Drive Downloader v1.1


Report a problem

Content text 19_Eloquent Javascript 2014.pdf

Eloquent JavaScript A Modern Introduction to Programming Marijn Haverbeke
Copyright © 2014 by Marijn Haverbeke This work is licensed under a Creative Commons attribution-noncommercial license (http://creativecommons.org/licenses/by-nc/3.0/). All code in the book may also be considered licensed under an MIT license (http://opensource. org/licenses/MIT). The illustrations are contributed by various artists: Cover by Wasif Hyder. Computer (introduction) and unicycle people (Chapter 21) by Max Xiantu. Sea of bits (Chapter 1) and weresquirrel (Chapter 4) by Margarita Martínez and José Menor. Octopuses (Chapter 2 and 4) by Jim Tierney. Object with on/off switch (Chapter 6) by Dyle MacGre- gor. Regular expression diagrams in Chapter 9 generated with regex- per.com by Jeff Avallone. Game concept for Chapter 15 by Thomas Palef. Pixel art in Chapter 16 by Antonio Perdomo Pastor. The second edition of Eloquent JavaScript was made possible by 454 financial backers. You can buy a print version of this book, with an extra bonus chapter included, printed by No Starch Press at http://www.amazon.com/gp/product/ 1593275846/ref=as_li_qf_sp_asin_il_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN= 1593275846&linkCode=as2&tag=marijhaver-20&linkId=VPXXXSRYC5COG5R5. i
Contents On programming . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Why language matters . . . . . . . . . . . . . . . . . . . . . . . 5 What is JavaScript? . . . . . . . . . . . . . . . . . . . . . . . . . 9 Code, and what to do with it . . . . . . . . . . . . . . . . . . . 11 Overview of this book . . . . . . . . . . . . . . . . . . . . . . . . 12 Typographic conventions . . . . . . . . . . . . . . . . . . . . . . 14 1 Values, Types, and Operators 15 Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Unary operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Boolean values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Undefined values . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Automatic type conversion . . . . . . . . . . . . . . . . . . . . . 27 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 2 Program Structure 32 Expressions and statements . . . . . . . . . . . . . . . . . . . . 32 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 ii
Keywords and reserved words . . . . . . . . . . . . . . . . . . . 37 The environment . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 The console.log function . . . . . . . . . . . . . . . . . . . . . . 39 Return values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 prompt and confirm . . . . . . . . . . . . . . . . . . . . . . . . . 40 Control flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Conditional execution . . . . . . . . . . . . . . . . . . . . . . . . 42 while and do loops . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Indenting Code . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 for loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Breaking Out of a Loop . . . . . . . . . . . . . . . . . . . . . . 49 Updating variables succinctly . . . . . . . . . . . . . . . . . . . 51 Dispatching on a value with switch . . . . . . . . . . . . . . . . 51 Capitalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 3 Functions 59 Defining a function . . . . . . . . . . . . . . . . . . . . . . . . . 59 Parameters and scopes . . . . . . . . . . . . . . . . . . . . . . . 61 Nested scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Functions as values . . . . . . . . . . . . . . . . . . . . . . . . . 65 Declaration notation . . . . . . . . . . . . . . . . . . . . . . . . 66 The call stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Optional Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 69 iii

Related document

x
Report download errors
Report content



Download file quality is faulty:
Full name:
Email:
Comment
If you encounter an error, problem, .. or have any questions during the download process, please leave a comment below. Thank you.