You are previewing JavaScript: 20 Lessons to Successful Web Development.
O'Reilly logo
JavaScript: 20 Lessons to Successful Web Development

Book Description

Master JavaScript in 20 lessons--online video tutorials included!

Based on the author's successful online courses, this complete, integrated learning tool provides easy-to-follow lessons that feature clear explanations, sample code and exercises, and video tutorials. Each lesson is designed to take you less than an hour to complete.

JavaScript: 20 Lessons to Successful Web Development covers the basics, including variables, operators, arrays, objects, and values. Next, you'll learn how to use conditional statements, work with multidimensional arrays, manipulate objects, handle errors, manage cookies, use Ajax, and much more. Together, the book and almost five hours of video training make learning JavaScript easier than ever!

Ready-to-use code at www.mhprofessional.com

Table of Contents

  1. Cover
  2. Title Page
  3. Copyright Page
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. Acknowledgments
  8. Introduction
  9. PART I JavaScript Basics
    1. LESSON 1 Introduction to JavaScript
      1. In the Beginning
        1. In-browser Scripting
      2. Info for Programmers
        1. All About Objects
      3. Why You Need to Know JavaScript
      4. Summary
      5. Self-Test Questions
    2. LESSON 2 Incorporating JavaScript into a Web Page
      1. Using Comments
        1. Using Semicolons
      2. Where to Place the JavaScript Code
        1. In the Document Head
        2. In the Document Body
        3. Including JavaScript Files
      3. JavaScript Language Syntax
        1. Case Sensitivity
        2. Whitespace
      4. Variables
        1. Variable Naming
        2. String Variables
        3. Variable Typing and Casting
      5. Summary
      6. Self-Test Questions
    3. LESSON 3 Working with Arithmetic Operators and Functions
      1. Arithmetic Operators
        1. Pre-Incrementing
        2. Post-Incrementing
        3. Pre- and Post-Decrementing
      2. Arithmetic Functions
      3. Assignment Operators
      4. Summary
      5. Self-Test Questions
    4. LESSON 4 Applying Comparison and Logical Operators
      1. Comparison Operators
      2. Logical Operators
        1. The Ternary Operator
        2. Bitwise Operators
      3. Operator Precedence
      4. Operator Associativity
      5. The with Keyword
      6. Summary
      7. Self-Test Questions
    5. LESSON 5 Creating JavaScript Arrays
      1. Array Names
      2. Creating an Array
        1. Creating an Array of Specific Length
        2. Assigning Values to an Array Element
        3. Using Indexes
        4. Retrieving Values
        5. Using Array Elements as Indexes
      3. Other Ways of Creating Arrays
      4. Using Associative Arrays
        1. Keys, Values, and Hash Tables
        2. Other Ways of Creating an Associative Array
      5. Summary
      6. Self-Test Questions
    6. LESSON 6 Accessing Multidimensional Arrays
      1. Creating a Two-Dimensional Array
      2. Accessing a Two-Dimensional Array
      3. A More Practical Example
      4. Multidimensional Associative Arrays
        1. Creating the Multidimensional Array
        2. Accessing the Arrays
      5. Summary
      6. Self-Test Questions
    7. LESSON 7 Calling Array Functions
      1. Using for (… in …)
      2. Using concat()
        1. An Alternative to concat()
      3. Using join()
      4. The forEach() Function
      5. The map() Function
      6. Summary
      7. Self-Test Questions
  10. PART II Advanced JavaScript
    1. LESSON 8 Pushing to and Popping from Arrays
      1. Using push()
      2. Using pop()
      3. Using push() and pop() Together
      4. Using reverse()
      5. Using Stacks and Buffers
        1. Buffering Using an Array
        2. Creating a Function for Pushing to the Top
      6. Summary
      7. Self-Test Questions
    2. LESSON 9 Advanced Array Manipulation
      1. Using sort()
        1. Tailoring the sort() Function
        2. Sorting Numerically
        3. Reversing a Sort
      2. Using splice()
        1. Removing Elements from an Array
        2. Inserting Elements into an Array
        3. Advanced Array Splicing
      3. Summary
      4. Self-Test Questions
    3. LESSON 10 Controlling Program Flow
      1. The if() Statement
        1. Omitting the Braces
        2. Positioning of Braces
      2. The else Statement
        1. The else if() Statement
      3. The switch() Statement
        1. Using the break Keyword
        2. Using the default Keyword
        3. Allowing Fall-Through
      4. Summary
      5. Self-Test Questions
    4. LESSON 11 Looping Sections of Code
      1. Using while() Loops
        1. The Example in Detail
      2. Using do … while() Loops
        1. The Example in Detail
      3. Using for() Loops
        1. The Example in Detail
      4. Using for(… in …) Loops
        1. Breaking Out of a Loop
        2. The continue Statement
      5. Summary
      6. Self-Test Questions
    5. LESSON 12 Writing Functions
      1. Using Functions
        1. The return Keyword
        2. Passing Arguments
        3. Accessing Arguments
        4. Using the arguments Object
        5. Using the this Keyword
      2. Anonymous Functions
      3. Global and Local Variable Scope
        1. Using Local Variables
      4. Global Naming Convention
      5. Summary
      6. Self-Test Questions
    6. LESSON 13 Manipulating JavaScript Objects
      1. Declaring a Class
        1. Creating an Object
        2. Accessing Objects
      2. The prototype Keyword
        1. Extending JavaScript Functions
      3. Summary
      4. Self-Test Questions
    7. LESSON 14 Handling Errors and Regular Expressions
      1. Using onerror
        1. Limiting the Scope of onerror
      2. Using try … catch()
        1. Ignoring the Error
      3. Regular Expressions
      4. Using test()
      5. Using replace()
        1. Replacing Globally
        2. Fuzzy Matching
        3. Matching Any Character
        4. Not Matching a Character
      6. Summary
      7. Self-Test Questions
    8. LESSON 15 Interacting with the Document Object Model
      1. The DOM
      2. Accessing the DOM from JavaScript
        1. Using the getElementById() Function
        2. The Simpler O() Function
        3. The Partner S() Function
        4. Accessing Multiple Elements by Class
        5. Using the C() Function
        6. The Difference Between Properties in CSS and JavaScript
        7. Summary of the Three Functions
      3. Some Common Properties
        1. Other Properties
      4. Summary
      5. Self-Test Questions
    9. LESSON 16 Inserting Inline JavaScript and Events
      1. Inline JavaScript
        1. Another Instance of this
        2. Non-inline Event Attaching
        3. Attaching to Other Events
        4. Adding New Elements
        5. Removing Elements
        6. Alternatives to Adding and Removing Elements
      2. Controlling HTML5 Media
      3. Summary
      4. Self-Test Questions
    10. LESSON 17 Controlling Cookies and Local Storage
      1. Using Cookies
        1. Setting a Cookie
        2. Reading a Cookie
        3. Deleting a Cookie
      2. Using Local Storage
        1. Removing and Clearing Local Data
      3. Summary
      4. Self-Test Questions
    11. LESSON 18 Working with Different Browsers
      1. The User Agent String
        1. The GetBrowser() Function
      2. The Query String
        1. The GetQueryString() Function
      3. Summary
      4. Self-Test Questions
    12. LESSON 19 Implementing Interrupts and Timeouts
      1. Using Interrupts
        1. Using setTimeout()
        2. Passing a String
        3. Repeating Timeouts
        4. Cancelling a Timeout
      2. Using setInterval()
        1. Using ShowTime()
        2. Cancelling an Interval
      3. A Simple Animation
      4. Web Workers
      5. Summary
      6. Self-Test Questions
    13. LESSON 20 Using Ajax
      1. Creating an Ajax Object
      2. The PostAjaxRequest() Function
      3. The GetAjaxRequest() Function
      4. The callback() Function
      5. The ajax.htm Example
      6. The ajax.php Program
      7. The ajax2.htm Example
      8. Ajax Security Restrictions
      9. The OnDOMReady() Function
      10. Summary
      11. Self-Test Questions
  11. PART III Appendixes
    1. APPENDIX A Answers to the Self-Test Questions
      1. Lesson 1 Answers
      2. Lesson 2 Answers
      3. Lesson 3 Answers
      4. Lesson 4 Answers
      5. Lesson 5 Answers
      6. Lesson 6 Answers
      7. Lesson 7 Answers
      8. Lesson 8 Answers
      9. Lesson 9 Answers
      10. Lesson 10 Answers
      11. Lesson 11 Answers
      12. Lesson 12 Answers
      13. Lesson 13 Answers
      14. Lesson 14 Answers
      15. Lesson 15 Answers
      16. Lesson 16 Answers
      17. Lesson 17 Answers
      18. Lesson 18 Answers
      19. Lesson 19 Answers
      20. Lesson 20 Answers
    2. APPENDIX B Common JavaScript Functions
      1. Arithmetic Functions
      2. Array Functions
      3. Boolean Functions
      4. Date Functions
      5. DOM Functions
      6. Global Functions
      7. Number Functions
      8. Regular Expression Functions
      9. String Functions
      10. Window Functions
  12. Index