You are previewing Learning from jQuery.
O'Reilly logo
Learning from jQuery

Book Description

If you’re comfortable with jQuery but a bit shaky with JavaScript, this concise guide will help you expand your knowledge of the language—especially the code that jQuery covers up for you. Many jQuery devotees write as little code as possible, but with some JavaScript under your belt, you can prevent errors, reduce overhead, and make your application code more efficient.

Table of Contents

  1. Special Upgrade Offer
  2. Preface
    1. Who This Book Is For
    2. Who This Book Isn’t For
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  3. 1. Event Handling
    1. Listening for Events
      1. Events in jQuery
      2. Events in JavaScript
      3. Events in Internet Explorer 8
      4. Writing a Wrapper Function
      5. Adding Event Handlers to Multiple Elements
    2. Event Propagation
      1. Internet Explorer’s .attachEvent
    3. Triggering Events
      1. Triggering Events in Internet Explorer 8
      2. Writing a Wrapper Function to Trigger Events
    4. Removing Event Handlers
      1. Removing Event Handlers in Internet Explorer 8
      2. Writing a Wrapper Function to Remove Events
    5. Adding a “Once Only” Event Listener
    6. Summary
  4. 2. Constructors and Prototypes
    1. Constructors
      1. Method Chaining
      2. Constructor, Not Function
    2. Prototypes
      1. .hasOwnProperty
      2. Editing the Prototype of Existing Objects
    3. Summary
  5. 3. DOM Traversal and Manipulation
    1. Selecting an Element
      1. Selecting Elements with a CSS Selector
    2. Selecting Children
    3. Selecting the Next Element
    4. Creating an Element
    5. Modifying an Existing Element
    6. Cycling Through Elements
    7. Moving and Copying Elements
    8. Summary
  6. 4. AJAX
    1. Sending an AJAX Request
    2. Debugging
      1. Debugging Sent AJAX Requests
    3. Sending POST Requests in JavaScript
    4. Writing a Wrapper Function
    5. A Simple Application of AJAX
    6. Designing a Site with AJAX
    7. Summary
  7. 5. JavaScript Conventions
    1. Writing JavaScript
      1. Comments
      2. Coding Standards
        1. Whitespace
        2. Curly braces
        3. Naming conventions
    2. Literals Notation
      1. Object Literals
      2. Other Literals
    3. Optimizations
      1. Algorithms
      2. Caching Variables
      3. parseInt
      4. Loops
      5. Minimize Repeated Expressions
    4. Functions
      1. Declarations Versus Expressions
      2. Function Callbacks
      3. If Invoking Self-Defining Functions
    5. Code Reuse
    6. Common Antipatterns
      1. Using eval
      2. with
      3. document.write
    7. Common Design Patterns
      1. The Singleton Pattern
      2. The Factory Pattern
      3. The Iterator Pattern
      4. The Facade Pattern
    8. Summary
  8. A. JavaScript Basics
    1. Hello World!
    2. Comments
    3. Variables
    4. Numbers
      1. The Assignment Operators
    5. Functions
      1. Hoisting Example
      2. Functions as Arguments
      3. Returning a Value
    6. Objects
    7. Finding the Type of a Variable
    8. Arrays
      1. Detecting an Array
    9. Looping
      1. The for Loop
      2. The while Loop
      3. The do-while Loop
      4. The break and continue Statements
      5. for..in statements
    10. Conditional Statements
      1. The if Statement
      2. Comparison Operators
      3. Logical Operators
        1. Falsy values
      4. The switch Statement
    11. Delays
    12. Regular Expressions
      1. Regular Expressions in String Functions
    13. Error Handling
    14. Summary
  9. B. JavaScript Resources
    1. A Good IDE
    2. GitHub
    3. JSHint
    4. JSPerf
    5. Mozilla Developer Network
    6. Pastebins
      1. Gist
      2. JSFiddle
    7. Version Control Software
  10. About the Author
  11. Colophon
  12. Special Upgrade Offer
  13. Copyright