Unearthing the Excellence in JavaScript
1234567

Most programming languages contain good and bad parts, but JavaScript has more than its share of the bad, having been developed and released in a hurry before it could be refined. This authoritative book scrapes away these bad features to reveal a subset of JavaScript that's more reliable, readable, and maintainable than the language as a whole—a subset you can use to create truly extensible and efficient code.

Considered the JavaScript expert by many people in the development community, author Douglas Crockford identifies the abundance of good ideas that make JavaScript an outstanding object-oriented programming language-ideas such as functions, loose typing, dynamic objects, and an expressive object literal notation. Unfortunately, these good ideas are mixed in with bad and downright awful ideas, like a programming model based on global variables.

When Java applets failed, JavaScript became the language of the Web by default, making its popularity almost completely independent of its qualities as a programming language. In JavaScript: The Good Parts, Crockford finally digs through the steaming pile of good intentions and blunders to give you a detailed look at all the genuinely elegant parts of JavaScript, including:

  • Syntax
  • Objects
  • Functions
  • Inheritance
  • Arrays
  • Regular expressions
  • Methods
  • Style
  • Beautiful features

The real beauty? As you move ahead with the subset of JavaScript that this book presents, you'll also sidestep the need to unlearn all the bad parts. Of course, if you want to find out more about the bad parts and how to use them badly, simply consult any other JavaScript book.

With JavaScript: The Good Parts, you'll discover a beautiful, elegant, lightweight and highly expressive language that lets you create effective code, whether you're managing object libraries or just trying to get Ajax to run fast. If you develop sites or applications for the Web, this book is an absolute must.

Douglas Crockford

Douglas Crockford is a Senior JavaScript Architect at Yahoo!, well known for introducing and maintaining the JSON (JavaScript Object Notation) format. He's a regular speaker at conferences on advanced JavaScript topics, and serves on the ECMAScript committee.

  • Chapter 1 Good Parts

    1. Why JavaScript?

    2. Analyzing JavaScript

    3. A Simple Testing Ground

  • Chapter 2 Grammar

    1. Whitespace

    2. Names

    3. Numbers

    4. Strings

    5. Statements

    6. Expressions

    7. Literals

    8. Functions

  • Chapter 3 Objects

    1. Object Literals

    2. Retrieval

    3. Update

    4. Reference

    5. Prototype

    6. Reflection

    7. Enumeration

    8. Delete

    9. Global Abatement

  • Chapter 4 Functions

    1. Function Objects

    2. Function Literal

    3. Invocation

    4. Arguments

    5. Return

    6. Exceptions

    7. Augmenting Types

    8. Recursion

    9. Scope

    10. Closure

    11. Callbacks

    12. Module

    13. Cascade

    14. Curry

    15. Memoization

  • Chapter 5 Inheritance

    1. Pseudoclassical

    2. Object Specifiers

    3. Prototypal

    4. Functional

    5. Parts

  • Chapter 6 Arrays

    1. Array Literals

    2. Length

    3. Delete

    4. Enumeration

    5. Confusion

    6. Methods

    7. Dimensions

  • Chapter 7 Regular Expressions

    1. An Example

    2. Construction

    3. Elements

  • Chapter 8 Methods

  • Chapter 9 Style

  • Chapter 10 Beautiful Features

  • Appendix Awful Parts

    1. Global Variables

    2. Scope

    3. Semicolon Insertion

    4. Reserved Words

    5. Unicode

    6. typeof

    7. parseInt

    8. +

    9. Floating Point

    10. NaN

    11. Phony Arrays

    12. Falsy Values

    13. hasOwnProperty

    14. Object

  • Appendix Bad Parts

    1. ==

    2. with Statement

    3. eval

    4. continue Statement

    5. switch Fall Through

    6. Block-less Statements

    7. ++ −−

    8. Bitwise Operators

    9. The function Statement Versus the function Expression

    10. Typed Wrappers

    11. new

    12. void

  • Appendix JSLint

    1. Undefined Variables and Functions

    2. Members

    3. Options

    4. Semicolon

    5. Line Breaking

    6. Comma

    7. Required Blocks

    8. Forbidden Blocks

    9. Expression Statements

    10. for in Statement

    11. switch Statement

    12. var Statement

    13. with Statement

    14. =

    15. == and !=

    16. Labels

    17. Unreachable Code

    18. Confusing Pluses and Minuses

    19. ++ and −−

    20. Bitwise Operators

    21. eval Is Evil

    22. void

    23. Regular Expressions

    24. Constructors and new

    25. Not Looked For

    26. HTML

    27. JSON

    28. Report

  • Appendix Syntax Diagrams

  • Appendix JSON

    1. JSON Syntax

    2. Using JSON Securely

    3. A JSON Parser

  • Colophon