Publisher: O'Reilly Media Released: September 2010 Pages: 234
What's the best approach for developing an application with JavaScript? This book helps you answer that question with numerous JavaScript coding patterns and best practices. If you're an experienced developer looking to solve problems related to objects, functions, inheritance, and other language-specific categories, the abstractions and code templates in this guide are ideal -- whether you're writing a client-side, server-side, or desktop application with JavaScript. Written by JavaScript expert Stoyan Stefanov -- Senior Yahoo! Technical and architect of YSlow 2.0, the web page performance optimization tool -- JavaScript Patterns includes practical advice for implementing each pattern discussed, along with several hands-on examples. You'll also learn about anti-patterns: common programming approaches that cause more problems than they solve. - Explore useful habits for writing high-quality JavaScript code, such as avoiding globals, using single var declarations, and more
- Learn why literal notation patterns are simpler alternatives to constructor functions
- Discover different ways to define a function in JavaScript
- Create objects that go beyond the basic patterns of using object literals and constructor functions
- Learn the options available for code reuse and inheritance in JavaScript
- Study sample JavaScript approaches to common design patterns such as Singleton, Factory, Decorator, and more
- Examine patterns that apply specifically to the client-side browser environment
|
-
Chapter 1 Introduction -
Patterns -
JavaScript: Concepts -
ECMAScript 5 -
JSLint -
The Console -
Chapter 2 Essentials -
Writing Maintainable Code -
Minimizing Globals -
for Loops -
for-in Loops -
(Not) Augmenting Built-in Prototypes -
switch Pattern -
Avoiding Implied Typecasting -
Number Conversions with parseInt() -
Coding Conventions -
Naming Conventions -
Writing Comments -
Writing API Docs -
Writing to Be Read -
Peer Reviews -
Minify…In Production -
Run JSLint -
Summary -
Chapter 3 Literals and Constructors -
Object Literal -
Custom Constructor Functions -
Patterns for Enforcing new -
Array Literal -
JSON -
Regular Expression Literal -
Primitive Wrappers -
Error Objects -
Summary -
Chapter 4 Functions -
Background -
Callback Pattern -
Returning Functions -
Self-Defining Functions -
Immediate Functions -
Immediate Object Initialization -
Init-Time Branching -
Function Properties—A Memoization Pattern -
Configuration Objects -
Curry -
Summary -
Chapter 5 Object Creation Patterns -
Namespace Pattern -
Declaring Dependencies -
Private Properties and Methods -
Module Pattern -
Sandbox Pattern -
Static Members -
Object Constants -
Chaining Pattern -
method() Method -
Summary -
Chapter 6 Code Reuse Patterns -
Classical Versus Modern Inheritance Patterns -
Expected Outcome When Using Classical Inheritance -
Classical Pattern #1—The Default Pattern -
Classical Pattern #2—Rent-a-Constructor -
Classical Pattern #3—Rent and Set Prototype -
Classical Pattern #4—Share the Prototype -
Classical Pattern #5—A Temporary Constructor -
Klass -
Prototypal Inheritance -
Inheritance by Copying Properties -
Mix-ins -
Borrowing Methods -
Summary -
Chapter 7 Design Patterns -
Singleton -
Factory -
Iterator -
Decorator -
Strategy -
Façade -
Proxy -
Mediator -
Observer -
Summary -
Chapter 8 DOM and Browser Patterns -
Separation of Concerns -
DOM Scripting -
Events -
Long-Running Scripts -
Remote Scripting -
Deploying JavaScript -
Loading Strategies -
Summary -
Colophon |
- Title:
- JavaScript Patterns
- By:
- Stoyan Stefanov
- Publisher:
- O'Reilly Media
- Formats:
-
- Print
- Ebook
- Safari Books Online
- Print:
- September 2010
- Ebook:
- September 2010
- Pages:
- 234
- Print ISBN:
- 978-0-596-80675-0
- | ISBN 10:
- 0-596-80675-2
- Ebook ISBN:
- 978-0-596-80677-4
- | ISBN 10:
- 0-596-80677-9
|
-
Stoyan Stefanov Stoyan Stefanov is a Yahoo! web developer, Zend Certified Engineer, and an author, contributor, and tech reviewer of various O'Reilly books. He speaks regularly about web development topics at conferences and on his blog at www.phpied.com. Stoyan is the creator of the smush.it image optimization tool and architect of Yahoo's performance optimization tool YSlow 2.0. View Stoyan Stefanov's full profile page. |
Colophon The animal on the cover of JavaScript Patterns is a European partridge (Perdix perdix), also called a gray partridge, English partridge, Hungarian partridge, or Bohemian partridge. This widespread bird is native to Europe and western Asia, but it has been introduced in North America and is now common in some parts of southern Canada and the northern United States. Partridges are members of the pheasant family, Phasianidae. They are nonmigratory ground-nesters that eat mainly grain and seeds. Originally residents of grasslands, they became adapted to and spread with human agriculture; they are now most often found near cultivated fields. European partridges are rotund, chicken-like birds (about 12 inches long) with short necks and tails. They have brown backs, gray underparts (with a dark chestnut belly patch), rusty faces, and dull bills and legs. Their clutches, consisting of 15 to 20 eggs, are among the largest of any bird. Widely introduced as gamebirds, partridges were extensively hunted in the late 1800s and early 1900s. The bird’s scientific name comes from Perdix of Greek mythology, the nephew of the inventor Daedalus. Daedalus was jealous of his young student—credited with having invented the saw, the chisel, the geometric compass, and the potter’s wheel—and seized an opportunity to shove him off of the Acropolis. Athena, sympathetic to the clever boy, came to his rescue and turned him into a partridge, a bird that avoids heights and prefers to nest on the ground. The cover image is from Johnson’s Natural History. The cover font is Adobe ITC Garamond. The text font is Linotype Birka; the heading font is Adobe Myriad Condensed; and the code font is LucasFont’s TheSansMonoCondensed. |
|
Description
|
Table of Contents
|
Product Details
|
About the Author
|
Colophon
|
 |
|
 |
|
|
|
Recommended for You
|
Recently Viewed
|
 |
|
By Ken Pepple
July 2011
Ebook: $17.99
Print & Ebook: $27.49
Print: $24.99
By Rob Cameron, Brad Woodberg, Patricio Giecco, Timothy Eberhard, James Quinn
August 2010
Ebook: $55.99
Print & Ebook: $82.49
Print: $74.99
By Paul Teetor
January 2011
Ebook: $15.99
Print & Ebook: $21.99
Print: $19.99
|
Customer Reviews
- Accurate
- Concise
- Easy to understand
- Helpful examples
- Well-written
7/7/2011 3.0Fair read, although a bit unbalanced - Accurate
- Easy to understand
- Useful as reference
- Well-written
6/15/2011 4.0Well done - Highly recommended By Jon Frost from Missouri About Me Developer, Educator, SVG and Net developer - Accurate
- Concise
- Easy to understand
- Helpful examples
- Well-written
- Intermediate
- Novice
- Student
5/31/2011 (0 of 7 customers found this review helpful) 1/12/2011 (2 of 2 customers found this review helpful) 5.0Excellent for intermediate JavaScript By bhofmann from Exmouth, England - Accurate
- Concise
- Easy to understand
- Helpful examples
- Well-written
- Intermediate
- Novice
- Student
11/18/2010 (2 of 6 customers found this review helpful) 4.0Excellent for professional developers By ArpitNext from New Delhi, India - Accurate
- Easy to understand
- Helpful examples
- Well-written
11/15/2010 (7 of 7 customers found this review helpful) By Michael from Olathe, KS - Accurate
- Concise
- Easy to understand
- Helpful examples
- Well-written
|
|
|
Merchant response: Thank you for letting us know about this error. It has been submitted on the book's errata page (http://oreilly.com/catalog/errataunconfirmed.csp?isbn=9780596806767 ) and if it is confirmed, it will be corrected in future printings. If you find any more errors, please submit it at http://www.oreillynet.com/cs/catalog/create/errata/?b=5099
Regards,
Rachel James
O'Reilly Media