Preface |
|
xi | |
Chapter 1 Introduction To Javascript |
|
1 | (36) |
|
Exploring the JavaScript Language |
|
|
1 | (6) |
|
Introducing Scripting Languages |
|
|
2 | (1) |
|
JavaScript and ECMAScript |
|
|
2 | (1) |
|
|
3 | (1) |
|
Understanding Client/Server Architecture |
|
|
4 | (1) |
|
JavaScript and Client-Side Scripting |
|
|
5 | (1) |
|
Understanding Server-Side Scripting |
|
|
6 | (1) |
|
Should You Use Client-Side or Server-Side Scripting? |
|
|
6 | (1) |
|
Writing a JavaScript Program |
|
|
7 | (7) |
|
|
7 | (2) |
|
|
9 | (1) |
|
|
9 | (1) |
|
Understanding JavaScript Objects |
|
|
10 | (1) |
|
|
10 | (3) |
|
Case Sensitivity in JavaScript |
|
|
13 | (1) |
|
Adding Comments to a JavaScript Program |
|
|
13 | (1) |
|
Writing Basic JavaScript Code |
|
|
14 | (3) |
|
|
14 | (1) |
|
|
15 | (1) |
|
Declaring and Initializing Variables |
|
|
15 | (2) |
|
Building Expressions with Variables |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
18 | (4) |
|
Working with Elements and Events |
|
|
19 | (2) |
|
Referencing Web Page Elements |
|
|
21 | (1) |
|
Structuring JavaScript Code |
|
|
22 | (1) |
|
Including a script Element for Each Code Section |
|
|
23 | (1) |
|
Placing the script Element |
|
|
23 | (1) |
|
Creating a JavaScript Source File |
|
|
23 | (4) |
|
Referencing an External File |
|
|
24 | (1) |
|
Using the async and defer Keywords |
|
|
24 | (1) |
|
Connecting to a JavaScript File |
|
|
25 | (1) |
|
|
26 | (1) |
|
|
27 | (1) |
|
|
28 | (1) |
|
|
29 | (1) |
|
|
30 | (1) |
|
|
31 | (4) |
|
|
35 | (2) |
Chapter 2 Working With Functions, Data Types, And Operators |
|
37 | (40) |
|
|
38 | (4) |
|
|
38 | (1) |
|
|
39 | (2) |
|
|
41 | (1) |
|
Returning a Value from a Function |
|
|
41 | (1) |
|
Managing Events with Functions |
|
|
42 | (3) |
|
|
42 | (1) |
|
Events as Object Properties |
|
|
43 | (1) |
|
|
43 | (1) |
|
Events and Anonymous Functions |
|
|
44 | (1) |
|
Applying a Function to an Event |
|
|
44 | (1) |
|
Using Built-in JavaScript Functions |
|
|
45 | (1) |
|
Understanding Variable Scope |
|
|
45 | (3) |
|
let and var Declaration Scopes |
|
|
46 | (1) |
|
|
46 | (2) |
|
|
48 | (3) |
|
Working with Numeric Values |
|
|
48 | (1) |
|
Working with Boolean Values |
|
|
49 | (1) |
|
|
49 | (1) |
|
Escape Characters and Sequences |
|
|
50 | (1) |
|
Using Operators to Build Expressions |
|
|
51 | (6) |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
55 | (1) |
|
Understanding Falsy and Truthy Values |
|
|
55 | (1) |
|
|
56 | (1) |
|
|
57 | (1) |
|
Understanding Operator Precedence |
|
|
57 | (2) |
|
Using Expressions with Web Form Controls |
|
|
59 | (7) |
|
Working with Input Control Values |
|
|
59 | (2) |
|
|
61 | (3) |
|
Using the change Event with Web Form Controls |
|
|
64 | (2) |
|
Locating Errors with the Browser Console |
|
|
66 | (2) |
|
Accessing the Browser Console |
|
|
66 | (1) |
|
Locating an Error in Your Program |
|
|
67 | (1) |
|
|
68 | (1) |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
71 | (5) |
|
|
76 | (1) |
Chapter 3 Building Arrays And Controlling Flow |
|
77 | (40) |
|
|
77 | (6) |
|
Declaring and Initializing Arrays |
|
|
78 | (1) |
|
|
79 | (1) |
|
|
79 | (3) |
|
|
82 | (1) |
|
Exploring HTML Collections |
|
|
83 | (2) |
|
Referencing an Element within a Collection |
|
|
83 | (1) |
|
Searching through the DOM |
|
|
84 | (1) |
|
Viewing Arrays and HTML Collections with the Console |
|
|
85 | (1) |
|
Working with Program Loops |
|
|
86 | (8) |
|
|
86 | (3) |
|
|
89 | (1) |
|
|
89 | (2) |
|
|
91 | (3) |
|
Exploring Array Methods for Generating Loops |
|
|
94 | (2) |
|
Adding Decision Making to Your Code |
|
|
96 | (9) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
97 | (3) |
|
Nested if and if else Statements |
|
|
100 | (1) |
|
Conditional Statements and Browser Testing |
|
|
101 | (1) |
|
|
102 | (3) |
|
Managing Program Loops and Conditional Statements |
|
|
105 | (2) |
|
|
105 | (1) |
|
|
105 | (1) |
|
|
105 | (2) |
|
|
107 | (1) |
|
|
107 | (1) |
|
|
108 | (1) |
|
|
109 | (7) |
|
|
116 | (1) |
Chapter 4 Debugging And Error Handling |
|
117 | (46) |
|
Introduction to Debugging |
|
|
117 | (4) |
|
|
118 | (1) |
|
|
119 | (1) |
|
|
120 | (1) |
|
Starting Debugging with the Browser Console |
|
|
121 | (4) |
|
Running Javascript in Strict Mode |
|
|
125 | (2) |
|
Tracing Errors to Their Source |
|
|
127 | (9) |
|
Tracing Errors with the window.alert() Method |
|
|
127 | (4) |
|
Tracing Errors with the Console Log |
|
|
131 | (4) |
|
Using Comments to Locate Bugs |
|
|
135 | (1) |
|
Tracking Program Flow with Debugging Tools |
|
|
136 | (9) |
|
Accessing your Browser's Debugging Tools |
|
|
136 | (1) |
|
Adding and Removing Break Points |
|
|
137 | (3) |
|
Stepping through the Program Execution |
|
|
140 | (1) |
|
Tracking Variables and Expressions |
|
|
141 | (2) |
|
|
143 | (2) |
|
|
145 | (5) |
|
Handling Exceptions with the try catch Statement |
|
|
145 | (1) |
|
|
146 | (1) |
|
The try catch finally Statement |
|
|
146 | (1) |
|
The error Parameter in the catch Statement |
|
|
147 | (1) |
|
Applying Exception Handling to a Program |
|
|
147 | (3) |
|
Customizing Your Error Handling |
|
|
150 | (2) |
|
Catching Errors with the error Event |
|
|
150 | (1) |
|
|
151 | (1) |
|
|
152 | (1) |
|
|
153 | (1) |
|
|
153 | (1) |
|
|
154 | (6) |
|
|
160 | (3) |
Chapter 5 Creating A Web APP Using The Document Object Model |
|
163 | (46) |
|
|
163 | (2) |
|
|
165 | (12) |
|
Nodes and the Document Object Model |
|
|
166 | (2) |
|
Selecting Nodes with the querySelectorAll () Method |
|
|
168 | (1) |
|
Creating and Connecting Nodes |
|
|
168 | (1) |
|
Elements Nodes and HTML Attributes |
|
|
169 | (1) |
|
|
170 | (1) |
|
Creating a Document Fragment in an App |
|
|
170 | (3) |
|
Viewing Elements within the Browser Debugger |
|
|
173 | (4) |
|
Restructuring a Node Tree |
|
|
177 | (4) |
|
Moving Nodes with the appendChild () Method |
|
|
177 | (2) |
|
Moving Nodes with the insertBefore () Method |
|
|
179 | (2) |
|
|
181 | (1) |
|
|
181 | (3) |
|
Repeating Commands at Specified Intervals |
|
|
181 | (1) |
|
|
182 | (1) |
|
Using Time-Delayed Commands |
|
|
183 | (1) |
|
Working with Popup Windows |
|
|
184 | (4) |
|
|
184 | (1) |
|
Working with Browser Windows |
|
|
185 | (2) |
|
Writing Content to a Browser Window |
|
|
187 | (1) |
|
Limitations of Browser Windows |
|
|
187 | (1) |
|
|
188 | (5) |
|
Introducing the this Object |
|
|
190 | (1) |
|
|
191 | (2) |
|
Exploring the Browser Object Model |
|
|
193 | (3) |
|
|
193 | (1) |
|
|
194 | (1) |
|
|
194 | (1) |
|
|
195 | (1) |
|
|
196 | (1) |
|
|
197 | (1) |
|
|
197 | (2) |
|
|
199 | (7) |
|
|
206 | (3) |
Chapter 6 Enhancing And Validating Forms |
|
209 | (44) |
|
Exploring Forms and Form Elements |
|
|
209 | (5) |
|
|
211 | (1) |
|
Working with Form Elements |
|
|
211 | (1) |
|
Properties and Methods of input Elements |
|
|
212 | (1) |
|
Navigating Between Input Controls |
|
|
213 | (1) |
|
Working with Selection Lists |
|
|
214 | (3) |
|
Working with Option Buttons |
|
|
217 | (3) |
|
Locating the Checked Option |
|
|
217 | (3) |
|
Accessing the Option Label |
|
|
220 | (1) |
|
Formatting Data Values in a Form |
|
|
220 | (3) |
|
|
220 | (1) |
|
Formatting Values Using a Locale String |
|
|
221 | (2) |
|
Responding to Form Events |
|
|
223 | (2) |
|
Working with Hidden Fields |
|
|
225 | (2) |
|
Exploring Form Submission |
|
|
227 | (1) |
|
|
227 | (1) |
|
|
227 | (1) |
|
Validating Form Data with JavaScript |
|
|
228 | (10) |
|
Working with the Constraint Validation API |
|
|
230 | (1) |
|
Exploring the ValidityState Object |
|
|
231 | (1) |
|
Creating a Custom Validation Message |
|
|
232 | (1) |
|
Responding to Invalid Data |
|
|
233 | (2) |
|
Validating Data with Pattern Matching |
|
|
235 | (1) |
|
Validating a Selection List |
|
|
236 | (2) |
|
Testing a Form Field Against a Regular Expression |
|
|
238 | (2) |
|
Creating a Custom Validity Check |
|
|
240 | (1) |
|
|
241 | (2) |
|
|
243 | (1) |
|
|
244 | (1) |
|
|
244 | (2) |
|
|
246 | (6) |
|
|
252 | (1) |
Chapter 7 Manipulating Data In Strings, Arrays, And Other Objects |
|
253 | (56) |
|
Retrieving Content from a Text File |
|
|
253 | (5) |
|
|
255 | (1) |
|
|
256 | (2) |
|
Working with Text Strings |
|
|
258 | (8) |
|
Searching for Substrings within a Text String |
|
|
259 | (2) |
|
|
261 | (2) |
|
Extracting Characters and Substrings |
|
|
263 | (1) |
|
|
264 | (1) |
|
|
265 | (1) |
|
Introducing Regular Expressions |
|
|
266 | (8) |
|
|
266 | (1) |
|
Setting Regular Expression Flags |
|
|
267 | (1) |
|
Defining Character Types and Character Classes |
|
|
268 | (2) |
|
Specifying Repeating Characters |
|
|
270 | (2) |
|
|
272 | (1) |
|
Specifying Alternate Patterns and Grouping |
|
|
273 | (1) |
|
Programming with Regular Expressions |
|
|
274 | (6) |
|
Regular Expression Methods |
|
|
275 | (1) |
|
Replacing Text with Regular Expressions |
|
|
276 | (2) |
|
Splitting a Text String into an Array |
|
|
278 | (1) |
|
Referencing Substring Matches |
|
|
279 | (1) |
|
|
280 | (12) |
|
Reversing and Sorting an Array |
|
|
281 | (3) |
|
Sorting with a Compare Function |
|
|
284 | (2) |
|
Extracting and Inserting Array Items |
|
|
286 | (1) |
|
Using Arrays as Data Stacks |
|
|
287 | (5) |
|
Exploring the Math Object |
|
|
292 | (2) |
|
|
292 | (1) |
|
|
292 | (1) |
|
Applying a Math Method to an Array |
|
|
293 | (1) |
|
Random Numbers and Random Sorting |
|
|
294 | (1) |
|
Exploring the Date Object |
|
|
294 | (3) |
|
Extracting Information from Dates and Times |
|
|
295 | (1) |
|
Setting Date and Time Values |
|
|
296 | (1) |
|
Exploring Template Literals |
|
|
297 | (2) |
|
Adding Placeholders to Template Literals |
|
|
297 | (1) |
|
Tagging a Template Literal |
|
|
297 | (2) |
|
|
299 | (1) |
|
|
300 | (1) |
|
|
300 | (1) |
|
|
301 | (7) |
|
|
308 | (1) |
Chapter 8 Creating Customized Objects, Properties, And Methods |
|
309 | (54) |
|
Understanding Object-Oriented Programing |
|
|
309 | (3) |
|
|
310 | (1) |
|
Understanding Encapsulation |
|
|
310 | (2) |
|
Creating an Object Literal |
|
|
312 | (6) |
|
Dot Operators and Bracket Notation |
|
|
313 | (2) |
|
|
315 | (2) |
|
Creating an Object with the new Operator |
|
|
317 | (1) |
|
Working with Object Classes |
|
|
318 | (9) |
|
Understanding Object Classes |
|
|
318 | (1) |
|
Object Constructors and Literals |
|
|
318 | (1) |
|
|
319 | (1) |
|
|
320 | (7) |
|
Working with Object Prototypes |
|
|
327 | (4) |
|
|
327 | (2) |
|
Extending Built-in javaScript Objects |
|
|
329 | (2) |
|
|
331 | (7) |
|
|
331 | (1) |
|
Closures and the Lexical Environment |
|
|
332 | (2) |
|
|
334 | (4) |
|
Working with Public, Private, and Privileged Methods |
|
|
338 | (5) |
|
Combining Objects with Prototype Chains |
|
|
343 | (4) |
|
Creating a Prototype Chain |
|
|
344 | (1) |
|
|
345 | (1) |
|
Using the apply () and call () Methods |
|
|
346 | (1) |
|
Data Storage with Associative Arrays |
|
|
347 | (4) |
|
The for in and for of Loops |
|
|
347 | (2) |
|
Storing Object data in jSON |
|
|
349 | (2) |
|
|
351 | (1) |
|
|
352 | (1) |
|
|
353 | (1) |
|
|
354 | (8) |
|
|
362 | (1) |
Chapter 9 Managing State Information And Security |
|
363 | (38) |
|
Understanding Sessions and State Information |
|
|
363 | (2) |
|
Sharing Data Between Forms |
|
|
365 | (6) |
|
Retrieving the Query String Text using the Location object |
|
|
367 | (1) |
|
Replacing URI Encoding Characters |
|
|
368 | (3) |
|
|
371 | (1) |
|
|
371 | (1) |
|
Local Storage and Session Storage Objects |
|
|
371 | (1) |
|
Storing Data in Web Storage |
|
|
372 | (7) |
|
Viewing Web Storage Items in your Browser |
|
|
374 | (1) |
|
Retrieving Items with the get Item () Method |
|
|
374 | (2) |
|
Removing Items from Web Storage |
|
|
376 | (1) |
|
|
377 | (1) |
|
Web Storage and the Same-Origin Policy |
|
|
378 | (1) |
|
|
379 | (2) |
|
|
379 | (1) |
|
The Structure of a Cookie |
|
|
380 | (1) |
|
Writing Data into a Cookie |
|
|
381 | (4) |
|
Setting the Cookie Expiration Date |
|
|
382 | (1) |
|
|
383 | (1) |
|
Setting the Cookie Domain |
|
|
383 | (1) |
|
|
383 | (1) |
|
A Function to Write the Cookie Value |
|
|
384 | (1) |
|
|
385 | (1) |
|
|
386 | (1) |
|
Exploring Security Issues |
|
|
386 | (3) |
|
Secure Coding with JavaScript |
|
|
387 | (1) |
|
JavaScript Security Concerns |
|
|
387 | (1) |
|
Using Third-Party Scripts |
|
|
388 | (1) |
|
|
389 | (1) |
|
|
389 | (1) |
|
|
390 | (1) |
|
|
391 | (8) |
|
|
399 | (2) |
Chapter 10 Programming With Event Objects And Third-Party APIS |
|
401 | (48) |
|
Working with Events as Objects |
|
|
402 | (4) |
|
|
402 | (1) |
|
Event Capturing and Bubbling |
|
|
403 | (3) |
|
Exploring Mouse, Touch, and Pointer Events |
|
|
406 | (4) |
|
|
407 | (2) |
|
Managing Multiple Touchpoints |
|
|
409 | (1) |
|
|
409 | (1) |
|
Programming a Drag and Drop Action |
|
|
410 | (5) |
|
Finding Event Coordinates |
|
|
411 | (2) |
|
Dragging and Dropping an Element |
|
|
413 | (2) |
|
Browser Tools for Touchscreen Emulation |
|
|
415 | (1) |
|
Exploring the Drag and Drop API |
|
|
415 | (3) |
|
The HTML Drag and Drop API |
|
|
416 | (1) |
|
Transferring Data with Drag and Drop |
|
|
417 | (1) |
|
Working with Keyboard Events |
|
|
418 | (3) |
|
Creating an Interactive Map |
|
|
421 | (5) |
|
Getting Started with the Google Maps API |
|
|
421 | (2) |
|
|
423 | (2) |
|
|
425 | (1) |
|
Mapping Your Position with Geolocation |
|
|
426 | (4) |
|
Adding Directions to a Map |
|
|
430 | (4) |
|
|
430 | (1) |
|
Displaying the Driving Route |
|
|
431 | (3) |
|
Introducing the Device Orientation API |
|
|
434 | (1) |
|
Preparing an App for Mobile Use |
|
|
435 | (2) |
|
|
435 | (1) |
|
|
435 | (1) |
|
|
435 | (2) |
|
|
437 | (1) |
|
|
437 | (1) |
|
|
438 | (1) |
|
|
439 | (7) |
|
|
446 | (3) |
Chapter 11 Managing Data Requests With AJAX And FETCH |
|
449 | (52) |
|
Introducing Server Requests |
|
|
450 | (2) |
|
|
452 | (2) |
|
Understanding HTTP Messages |
|
|
452 | (2) |
|
|
454 | (4) |
|
The XMLHttpRequest Object |
|
|
454 | (2) |
|
|
456 | (2) |
|
Viewing the Status of a Request and Response |
|
|
458 | (2) |
|
|
460 | (1) |
|
Introducing Arrow Functions |
|
|
461 | (3) |
|
Arrow Functions and Parameter Values |
|
|
462 | (2) |
|
Exploring the Promise Object |
|
|
464 | (3) |
|
Defining a Promise Object |
|
|
464 | (1) |
|
|
465 | (1) |
|
Running Multiple Promises |
|
|
466 | (1) |
|
|
467 | (5) |
|
|
467 | (1) |
|
Error Handling with Fetch |
|
|
468 | (1) |
|
Using Fetch to Return a Search |
|
|
469 | (3) |
|
|
472 | (4) |
|
|
473 | (1) |
|
Working with an XML Node Tree |
|
|
474 | (2) |
|
Creating an Autocomplete Search Box |
|
|
476 | (6) |
|
|
477 | (2) |
|
Building the Suggestion Box |
|
|
479 | (3) |
|
Working with Third-Party APIs |
|
|
482 | (4) |
|
|
482 | (1) |
|
|
483 | (3) |
|
Exploring Security Issues with APIs |
|
|
486 | (2) |
|
|
486 | (1) |
|
|
486 | (1) |
|
|
487 | (1) |
|
|
488 | (1) |
|
|
488 | (1) |
|
|
489 | (1) |
|
|
490 | (10) |
|
|
500 | (1) |
Chapter 12 Introducing jQuery |
|
501 | (34) |
|
Getting Started with jQuery |
|
|
501 | (4) |
|
|
502 | (1) |
|
|
502 | (1) |
|
Is jQuery still Relevant? |
|
|
503 | (2) |
|
Working with jQuery Selectors |
|
|
505 | (6) |
|
Selecting Elements from the DOM |
|
|
506 | (1) |
|
Traversing the DOM with jQuery |
|
|
507 | (1) |
|
Working with Attributes and CSS Properties |
|
|
508 | (1) |
|
Changing the DOM Structure |
|
|
509 | (2) |
|
Handling Events with jQuery |
|
|
511 | (4) |
|
Working with Effects and Animations |
|
|
515 | (5) |
|
|
516 | (1) |
|
Creating Custom Effects with Animate |
|
|
517 | (2) |
|
Controlling the Animation Queue |
|
|
519 | (1) |
|
|
520 | (4) |
|
|
524 | (1) |
|
|
524 | (1) |
|
|
525 | (1) |
|
|
526 | (7) |
|
|
533 | (2) |
Appendix A Installing And Configuring A Testing Server |
|
535 | (8) |
Appendix B Working With HTML And CSS |
|
543 | (6) |
Appendix C Solutions To Quick Checks |
|
Online | |
Glossary |
|
549 | (12) |
Index |
|
561 | |