Introduction 1 Parlez-vous JavaScript? 2 Contacting Me/Getting Help 3 Chapter 1 Hello, World! 5 What Is JavaScript? 7 Hello, World! 8 The HTML Document 8 Looking at the Code: Statements and Functions 11 PART I: THE BASIC STUFF Chapter 2 Values and Variables 15 Using Variables 16 More Variable Stuff 17 Naming Variables 17 More on Declaring and Initializing Variables 18 Chapter 3 Functions 21 What Is a Function? 23 A Simple Function 24 Creating a Function that Takes Arguments 28 Creating a Function that Returns Data 33 The Return Keyword 33 Exiting the Function Early 34 Chapter 4 Conditional Statements: If, Else, and Switch 37 The If / Else Statement 39 Meet the Conditional Operators 41 Creating More Complex Expressions 44 Variations on the If / Else Statement 45 Phew 47 Switch Statements 47 Using a Switch Statement 47 Similarity to an If/Else Statement 51 Deciding Which to Use 53 Chapter 5 Looping with For, While, and Do.While! 55 The for Loop 57 The Starting Point 61 The Step 61 The Condition (aka How Long to Keep Looping) 62 Putting It All Together 62 Some for Loop Examples 63 Breaking a Loop 63 Skipping an Iteration 64 Going Backwards 64 You Don''t Have to Use Numbers 65 Oh, No He Didn''t! 65 The Other Loops 66 The while Loop 66 The do.while Loop 66 Chapter 6 Commenting Your CodeFTW! 6 9 What Are Comments? 70 Single Line Comments 71 Multi-Line Comments 72 Commenting Best Practices 73 Chapter 7 Timers 77 Delaying with setTimeout 78 Looping with setInterval 79 Animating Smoothly with requestAnimationFrame 80 Chapter 8 Variable Scope 83 Global Scope 84 Local Scope 86 Miscellaneous Scoping Shenanigans 87 Block Scoping 87 How JavaScript Processes Variables 90 Closures 92 Chapter 9 Closures 93 Functions within Functions 94 When the Inner Functions Aren''t Self-Contained 98 Chapter 10 Where Should Your Code Live? 105 Approach #1: All the Code Lives in Your HTML Document 109 Approach #2: The Code Lives in a Separate File 110 The JavaScript File 110 Referencing the JavaScript File 111 So.Which Approach to Use? 114 Yes, My Code Will Be Used on Multiple Documents! 114 No, My Code Is Used Only Once on a Single HTML Document! 116 PART II: IT''S AN OBJECT-ORIENTED WORLD Chapter 11 Console Logging Basics 119 Meet the Console 120 Displaying the Console 121 If You Want to Follow Along 124 Console Logging 101 125 Meet the Log Method 125 Going Beyond Predefined Text 127 Displaying Warnings and Errors 128 Chapter 12 Of Pizza, Types, Primitives, and Objects 133 Let''s First Talk About Pizza 134 From Pizza to JavaScript! 136 What Are Objects? 138 The Predefined Objects Roaming Around in JavaScript 140 Chapter 13 Arrays 143 Creating an Array 144 Accessing Array Values 145 Adding Items to Your Array 147 Removing Items from the Array 149 Finding Items in the Array 150 Merging Arrays 150 Mapping, Filtering, and Reducing Arrays 151 The Old School Way 151 Modifying Each Array Item with Map 152 Filtering Items 154 Getting One Value from an Array of Items 155 A Short Foray into Functional Programming 157 Chapter 14 Strings 159 The Basics 160 String Properties and Methods 161 Accessing Individual Characters 161 Combining (aka Concatenating) Strings 163 Getting Substrings out of Strings 164 Splitting a String/split 165 Finding Something Inside a String 166 Upper and Lower Casing Strings 168 Chapter 15 When Primitives Behave Like Objects 169 Strings Aren''t the Only Problem 170 Let''s Pick on Strings Anyway 170 Why This Matters 172 Chapter 16 Numbers 175 Using a Number176 Operators 176 Doing Simple Math 177 Incrementing and Decrementing &n.
JavaScript Absolute Beginner's Guide