Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo
Programming JavaScript Applications

Book Description

Take advantage of JavaScript’s power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that’s easier—yes, easier—to work with as your code base grows.

Table of Contents

  1. Special Upgrade Offer
  2. Preface
    1. Introduction
    2. Who This Book Is For
    3. Who This Book Is Not For
    4. Unit Testing
    5. Conventions Used in This Book
    6. Safari® Books Online
    7. How to Contact Us
    8. Thanks
  3. 1. The JavaScript Revolution
    1. Advantages of JavaScript
      1. Performance
      2. Objects
      3. Syntax
      4. First-Class Functions
      5. Events
      6. Reusability
      7. The Net Result
    2. Anatomy of a Typical Modern JavaScript App
      1. Infrastructure
      2. JSON: Data Storage and Communication
      3. NoSQL Data Stores
      4. RESTful JSON Web Services
  4. 2. Functions
    1. Minimize Side Effects
    2. Function Definition
      1. Named Function Expressions
      2. Lambdas
      3. Immediately Invoked Function Expressions
      4. Method Context
        1. Function.prototype.bind()
    3. Function Scope
      1. Hoisting
      2. Closures
    4. Method Design
      1. Named Parameters
      2. Function Polymorphism
        1. Method dispatch
      3. Generics and Collection Polymorphism
      4. Method Chaining and Fluent APIs
    5. Functional Programming
      1. Stateless Functions (aka Pure Functions)
      2. Partial Application and Currying
    6. Asynchronous Operations
      1. Callbacks
      2. Promises and Deferreds
    7. Conclusion
  5. 3. Objects
    1. Classical Inheritance Is Obsolete
    2. Fluent-Style JavaScript
    3. Prototypes
      1. Delegate Prototypes
      2. Prototype Cloning
      3. The Flyweight Pattern
    4. Object Creation
    5. Factories
    6. Prototypal Inheritance with Stamps
    7. Conclusion
  6. 4. Modules
    1. Principles of Modularity
    2. Interfaces
    3. The Module Pattern
    4. Asynchronous Module Definition
      1. Plug-Ins
    5. Node-Style Modules
    6. npm
    7. ES6 Modules
    8. Building Client-Side Code with CommonJS, npm, Grunt, and Browserify
      1. Defining the App
      2. Feature Implementation
      3. Bundling and Deployment
    9. Conclusion
  7. 5. Separation of Concerns
    1. Client-Side Concerns
      1. Module Management
        1. Getting started
        2. Registration, loading, and rendering
      2. Events
        1. Event emitters
        2. Event aggregators
        3. Queues and stacks
        4. Choosing the right event model
        5. Events by example
      3. Model View Controller/MV*
      4. Presentation and DOM Manipulation
        1. View events
          1. Event delegation
        2. Templates
        3. Web Components
    2. Server-Side Concerns
      1. Getting Started with Node and Express
        1. Installing Node and Express
        2. Organizing files in Node
        3. Node libraries
        4. Configuration
        5. Express
        6. Create your app
        7. Routing
        8. Middleware
          1. Let it crash
        9. Templates
        10. Next steps
    3. Conclusion
  8. 6. Access Control
    1. Authentication
      1. Passwords
        1. Rainbow tables
          1. Password salts
        2. Brute force
        3. Variable time equality
        4. Stolen passwords
      2. Credential
      3. Multifactor Authentication
        1. Knowledge factor
        2. Possession factor
        3. Inherence factor
      4. Federated and Delegated Authentication
        1. Mozilla Persona
        2. WebID
        3. Delegated authentication
    2. Authorization
      1. Authorizing Applications
      2. OAuth 2.0
    3. Conclusion
  9. 7. Logging
    1. Debugging
    2. Server Operations
    3. Security
    4. Auditing
    5. Business Analytics
      1. Viral Factor
    6. Logging Checklist
    7. Logging Requests
    8. Logging Errors
    9. Sample Log Output
    10. Logging Service Alerts
    11. Logging Goals
    12. Profiling and Instrumentation
    13. Logging Client-Side Events
    14. Deciphering Data
    15. Conclusion
  10. 8. Building RESTful APIs
    1. Usable
      1. Focus
      2. Consistency
        1. Use common conventions
        2. Resourceful routing
    2. Self-Describing: Hypermedia
      1. Affordances
      2. HATEOAS
      3. HTML as an API Media Type
      4. Jade
      5. Jiron
    3. Responsive APIs
    4. Optimizing for Speed
    5. Conclusion
  11. 9. Feature Toggle
    1. Organizing Features
      1. Scale of a Feature
      2. Feature Groups
    2. Lifespan of a Feature
      1. Development
      2. Staging
      3. Production Testing
      4. Feature Rollout
      5. Default Activation
      6. Full Integration
    3. Implementation
    4. Conclusion
  12. 10. Internationalization
    1. Conclusion
  13. A. JavaScript Style Guide
    1. Example Tests
    2. QUnit Primer
    3. Code Quality
    4. Best Practices Quick Reference
      1. Indentation: Be Consistent
      2. Use Semicolons
      3. Bracket Placement: Right Side
      4. Avoid Name Collisions
      5. Always Use var
      6. Use One var Statement per Function
      7. Avoid Constant Abuse
      8. Use Functional Iterators When Possible
      9. Be Careful with if Statements
      10. Avoid Side Effects
      11. Don’t Use switch
      12. Don’t Use eval()
  14. Index
  15. About the Author
  16. Colophon
  17. Special Upgrade Offer
  18. Copyright