Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required.
Read instantly on your browser with Kindle for Web.
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the author
OK
JavaScript Patterns: Build Better Applications with Coding and Design Patterns 1st Edition
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 using JavaScript to write a client-side, server-side, or desktop application.
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
- ISBN-109780596806750
- ISBN-13978-0596806750
- Edition1st
- PublisherO'Reilly Media
- Publication dateOctober 26, 2010
- LanguageEnglish
- Dimensions7 x 0.6 x 9.19 inches
- Print length232 pages
Customers who viewed this item also viewed

Learning JavaScript Design Patterns: A JavaScript and React Developer's GuidePaperbackEUR 8.41 shippingOnly 9 left in stock (more on the way).
Customers also bought or read
- High Performance JavaScript: Build Faster Web Application Interfaces
PaperbackEUR14.22EUR14.22EUR 7.88 delivery Mon, May 11 - JavaScript: The Definitive Guide: Master the World's Most-Used Programming Language
PaperbackEUR53.86EUR53.86EUR 9.16 delivery Mon, May 11 - Design Patterns: Elements of Reusable Object-Oriented Software#1 Best SellerObject-Oriented Design
HardcoverEUR28.68EUR28.68EUR 9.08 delivery Thu, May 7 - The Road to React: Your journey to master plain yet pragmatic React.js
PaperbackEUR24.30EUR24.30EUR 8.41 delivery Thu, May 7 - Learning JavaScript Design Patterns: A JavaScript and React Developer's Guide
PaperbackEUR32.43EUR32.43EUR 8.41 delivery Thu, May 7 - Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript (Effective Software Development Series)
PaperbackEUR38.18EUR38.18EUR 8.16 delivery Fri, May 8 - Eloquent JavaScript, 3rd Edition: A Modern Introduction to Programming
PaperbackEUR10.96EUR10.96EUR 9.08 delivery Fri, May 8 - A Philosophy of Software Design, 2nd Edition#1 Best SellerMicrosoft Programming
PaperbackEUR19.58EUR19.58EUR 7.74 delivery Thu, May 7 - JavaScript Crash Course: A Hands-On, Project-Based Introduction to Programming
PaperbackEUR24.59EUR24.59EUR 8.81 delivery Thu, May 7
From the brand
-
Explore JavaScript resources
-
Explore TypeScript
-
Node.js
-
More from O'Reilly
-
Sharing the knowledge of experts
O'Reilly's mission is to change the world by sharing the knowledge of innovators. For over 40 years, we've inspired companies and individuals to do new things (and do them better) by providing the skills and understanding that are necessary for success.
Our customers are hungry to build the innovations that propel the world forward. And we help them do just that.
Editorial Reviews
About the Author
Product details
- ASIN : 0596806752
- Publisher : O'Reilly Media
- Publication date : October 26, 2010
- Edition : 1st
- Language : English
- Print length : 232 pages
- ISBN-10 : 9780596806750
- ISBN-13 : 978-0596806750
- Item Weight : 2.31 pounds
- Dimensions : 7 x 0.6 x 9.19 inches
- Best Sellers Rank: #1,704,156 in Books (See Top 100 in Books)
- #292 in JavaScript Programming (Books)
- #1,486 in Computer Programming Languages
- #3,877 in Programming Languages (Books)
- Customer Reviews:
About the author

Stoyan Stefanov leads a double life as a musician and a technologist in Los Angeles. In technology, he has twenty years of experience at the forefront of web programming and web performance in companies including Facebook/Meta/Instagram, Yahoo!, and SAP. As a thought leader and inventor, he has published about a dozen programming books and spoken at countless conferences around the world.
During his tech career, Stoyan has also played in several rock bands as a guitarist and songwriter, but it wasn't until Fall 2016 that he got serious about the art and craft of music. He started taking classes at Santa Monica College and the University of California, Los Angeles, in music theory, composition, conducting, orchestration, guitar, piano, viola, and more. Always curious, Stoyan is enchanted by anything and everything to do with music, from soldering audio gear to composing concert music, from collaborating with musicians on a song to recording, mixing, and releasing it. He has a single-item bucket list: to write orchestral music worthy of performance by the Los Angeles Philharmonic.
At the intersection of technology and music, Stoyan created and maintains OnlineMusicTools and SiteReadOrg: free websites for learning and improving the musicianship and theory skills of music students and practitioners.
Customer reviews
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonCustomers say
Generated from the text of customer reviewsSelect to learn more
Top reviews from the United States
There was a problem filtering reviews. Please reload the page.
- Reviewed in the United States on March 13, 2011Format: PaperbackVerified PurchaseI own the kindle and paperback versions of this book. An exceptional book!
This is a must have if you are serious about javascript programming. It is NOT a beginner's book and it doesnt waste whole chapters on a beginning javascript tutorial. To read this book, you should already know something about using prototypes and closures in js.
The first part of the book covers basic elements of the language such as types and declarations, for loops etc but this is a more advanced treatment. I learned something in every one of these sections. For example I had never really understood variable hoisting before.
After that the book seems to cover all the topics in Crockford's Javascript The Good parts, but with more explanation. His writing is clear and straightforward. Many software authors really dont know how to write clear English and give rambling, confusing explanations. On the other end of the scale, I found Crockford's book a bit cryptic at times. Why would you do inheritance this way?? Stefanov explains. You don't really need Crockford's book if you have this one. But JS The Good Parts is a classic.
The code examples are short and succint. This is not a cook book, nor a book with apps stretching over pages. In one chapter he does cover a complete app in some detail. But for the most part the code is short easily readable snippets well chosen to make his point. But this is not a code snippet resource. The examples he does give are written for clarity and are not optimized. Nor are they cluttered with code for dealing with special cases. You can find more sophisticated implementations of all these ideas on the web. The goal is to get the core idea.
The last part of the book covers such useful things as deployment, remote scripting and loading which are all very useful.
OReilly is currently offering a special deal where if you buy the kindle version, you can then buy the printed version for $5 !!. Which means you can get both for less than Amazon's price for the book alone. In addition, OReilly allows you to download, for free, unrestricted copies of the book in PDF & Mobi format. This deal is a no brainer. Note: OReilly's price for the ebook is much higher than Amazon's, but if you buy it from Amazon , you still get all these extras.
Cons: Doesn't cover ECMA 5 which is just coming out and includes some significant features and changes. I can't fault the author for that and the book is well worth it anyway. Doesn't discuss memory management which is a significant issue for the current version of JS with circular references causing memory leaks. This problem may go away in the new generation of browsers. Dunno. The book doesnt have a code download site. Even though this is not a cook book, I consider this a serious fault. It's nice to cut and past examples into a JS console and play with them as you read. Kindle for PC does not allow cut and paste. But in mitigation, The author's site has the code for the complete apps. I would have knocked off a star for this but in light of OReilly's generous offer and the fact that I would have rated this book 6 stars, I decided to let it go :)
- Reviewed in the United States on September 26, 2012Format: PaperbackVerified PurchaseMaster and beginner JavaScript developers alike have a reason to thank Stoyan Stefanov- he did a fantastic job surveying the JavaScript landscape and mapping out key strategies for us to use in writing JavaScript applications large and small. He explains JavaScript and how to use it properly very well in this book.
"JavaScript Patterns" is a thoughtful, thorough, and written manual on developing JavaScript applications in a patterns-based way. It excels in three main areas:
First, it explains with clear examples the difference between classical (e.g. class-like as in C++, Java, C#) language idioms of which many of us are indoctrinated and the more modern, functional, loose-type style of JavaScript. It is a good sell, as he argues convincingly for a more free and open understanding of what an Object can be in a Object-Orientated architecture. Most worth noting is how it so clearly explains the variety, prominence, and role of Functions in the language.
Second, it clearly shows through example many of the JavaScript "gotchas" like counter-intuitive hoisting rules and issues with unexpected typecasting. Each point comes with an example sophisticated enough to get the point across but without unneeded detail.
Finally, it dives into richer examples of the classical design patterns (Singleton, Factory, Decorator...) and how to apply them in JavaScript well using many of the OO patterns discussed earlier in the text.
High value in each Chapter
The "signal to noise" ratio in this text is very high. Very often authors, most notably Crockford, will go down a rabbit hole of pedantic unimportant threads. Stefanov keeps us on a focused course dedicating the most time to the subjects that really are core and matter in the language: Functions, Global Scope and Modules, building Objects.
The two exceptions to this are as follows:
His survey of Classical inheritance patterns is too involved. He spends many pages discussing the minutiae of slight differences in applying classical inheritance patterns to JavaScript, only to later argue that none of them should be used. That could have been explained to us without the long fruitless journey.
Some of the example Applications he uses to explain the patterns could have been refactored and simplified. Most notably his extended "Proxy" example missed the mark in trying to get the core pattern across because it was lost in too much unneeded application detail.
CoffeeScript and JavaScript
"JavaScript Patterns" is an absolute excellent text and can serve those writing server-side applications with JavaScript along with those using CoffeeScript to abbreviate the language. Even though CoffeeScript isn't mentioned, it explains the patterns that CoffeeScript uses when it compiles to JavaScript. To better understand what CoffeeScript is doing, read this book.
Top reviews from other countries
TanmayaReviewed in India on December 27, 20185.0 out of 5 stars Recommended to all javascript lovers
Format: PaperbackVerified PurchaseThis book explains JS patterns and basic concepts very clearly with examples. Topics are organised so wisely that it will generate interest to read the book. One of my best JS book so far. I recommend to all who has basic JS knowledge.
This book explains JS patterns and basic concepts very clearly with examples. Topics are organised so wisely that it will generate interest to read the book. One of my best JS book so far. I recommend to all who has basic JS knowledge.5.0 out of 5 stars
TanmayaRecommended to all javascript lovers
Reviewed in India on December 27, 2018
Images in this review
Michael SILVESTREReviewed in France on January 28, 20155.0 out of 5 stars A book that all JS developers should read
Format: KindleVerified PurchaseI really appreciate that book. It simple and don't use too much reference about main JS library such jQuery. It give advice about how to with good practice. It's easy to read and have a good place on my nightstand
I recommend this book and mainly all the book of that collection.
-
R. MoenchmeyerReviewed in Germany on March 6, 20135.0 out of 5 stars Exzellente Lektüre
Format: PaperbackVerified PurchaseIch entwickle serverseitig viel mit PHP5, u.a. für ein CMS-Framework. Javascript habe ich bisher lediglich für kleinere Applikationen/Animationen und im Zusammenhang mit Web-Formularen auf dem Browser eingesetzt. Natürlich kenne ich Flanagans einführendes Standardwerk. Und natürlich setze ich JQuery ein. Als extrem nützliches Framework überlagert und verdeckt JQuery aber die inherenten Möglichkeiten von Javascript durch eigene Strukturen und Interfaces.
Da ich nun immer mehr mit Ajax arbeite und hierfür eine Art "Miniframework" auf der Client-Seite aufbaue, habe ich begonnen, mich mehr und mehr um grundsätzliche Strukturierungs- Möglichkeiten und Patterns von Javascript zu kümmern. Dabei bin ich dann auf das Buch von S. Stefanov gestoßen. Und habe es in vielerlei Hinsicht als eine kleine Offenbarung empfunden.
Ich fand beim ersten Einstieg, dass der Autor ein ziemliches Tempo vorlegt und dass der Text sehr "dicht" geschrieben ist . Die ersten 50 Seiten sind zwar schnell überflogen. Aber das Niveau steigt dann schnell an. Kapitel 4, das versucht, dem Leser Funktionen als Objekte näher zu bringen, habe ich als ein Schlüsselkapitel empfunden. Alles, was danach kommt, fand ich erst dann in vielen Punkten spannend und lehrreich, nachdem ich Kapitel 4 nach zweimaligem Lesen ordentlich verdaut hatte. Aber so soll es sein - Mitdenken des Lesers ist zu Recht gefordert und es schadet nicht, immer mal wieder zurückzublättern.
Ich persönlich fand das Spektrum an Struktur-, Reuse- und Design-"Patterns", die der Autor beispielhaft in den Kapiteln 6 und 7 diskutiert, als relativ praxisnah, weil man die Beispiele schnell auf eigene Anforderungen übertragen kann. Hat man zudem einmal eine "Pattern"-Lektüre wie etwa das ebenfalls ausgezeichnete Buch "PHP Design Patterns" von Stefan Schmidt hinter sich gebracht, so wird man sich freuen, zu einigen der dort diskutierten Haupt-Patterns nun eine entsprechende Variante unter Javascript vorgestellt zu bekommen. Spätestens jetzt kann man sich vorstellen, Javascript auch in ganz anderen Umgebungen als einem Browser einzusetzen. Kapitel 8 zu DOM und dem browserspezifischen Einsatz von Javascript fand ich ein wenig kurz geraten. Aber das trübt den sehr guten Gesamteindruck nicht wesentlich.
Ich habe Stefanovs Buch inzwischen zum zweiten Mal gelesen. Und finde es nun exzellent. Der dichte Stil erwies sich beim erneuten Durchgang plötzlich als Vorteil. Ich finde auch, dass sich einem die didaktische Gedankenführung des Autors erst beim zweiten Lesen so richtig erschließt. Mein Respekt vor der Autor ist bei der zweiten Lektüre noch gestiegen.
Fazit: Der Autor macht es einem im ersten Anlauf sicher nicht leicht, ihm zu folgen. Aber die Anstrengung, die der Leser investieren muss, lohnt sich wirklich: Javascript hat durch das Buch für mich eine neue Bedeutung bekommen. Ich bewerte das Buch deshalb als ausgezeichnete Lektüre.
Paul BarberReviewed in the United Kingdom on March 8, 20155.0 out of 5 stars The focus is upon well designed code and good practices for writing maintainable JavaScript.
Format: PaperbackVerified PurchaseAvoids falling into the trap of simple 'hello world!' tutorials. Instead the focus is upon on well designed code and good practices for writing maintainable JavaScript code. If you already understand the basics of programming (even if you're completely new to JavaScript) I'd suggest skipping the simple tutorials and jumping into this, it's both easy to follow and very informative.
-
Cliente AmazonReviewed in Italy on May 2, 20185.0 out of 5 stars consigliatissimo
Format: PaperbackVerified Purchaseottimo libro per chi inizia a programmare in javascript. mi ha aperto un mondo che non conoscevo. un must da avere tra i propri libri










