JavaScript Patterns
Build Better Applications with Coding and Design Patterns
Publisher: O'Reilly Media
Final Release Date: September 2010
Pages: 236

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
Table of Contents
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
O'Reilly MediaJavaScript Patterns
 
4.3

(based on 10 reviews)

Ratings Distribution

  • 5 Stars

     

    (5)

  • 4 Stars

     

    (3)

  • 3 Stars

     

    (2)

  • 2 Stars

     

    (0)

  • 1 Stars

     

    (0)

100%

of respondents would recommend this to a friend.

Pros

  • Accurate (7)
  • Easy to understand (7)
  • Well-written (7)
  • Helpful examples (6)
  • Concise (5)

Cons

    Best Uses

    • Intermediate (7)
    • Student (4)
    • Expert (3)
      • Reviewer Profile:
      • Developer (9)

    Reviewed by 10 customers

    Sort by

    Displaying reviews 1-10

    Back to top

     
    5.0

    The best book on JS design pattern

    By Tomas Jurman

    from The Czech Republic

    About Me Developer

    Verified Buyer

    Pros

    • Accurate
    • Concise
    • Easy to understand
    • Helpful examples
    • Well-written

    Cons

      Best Uses

      • Intermediate
      • Student

      Comments about O'Reilly Media JavaScript Patterns:

      I was very satisfied. Everything is well explained with clear examples. I've read several books on design patterns, but this was the best for me.

      (1 of 1 customers found this review helpful)

       
      5.0

      superb

      By Paul

      from Wiltshire, UK

      About Me Developer

      Verified Reviewer

      Pros

        Cons

          Best Uses

            Comments about O'Reilly Media JavaScript Patterns:

            having read the definitive guide and crockford, this is the logical next book to read. I refer back to this book constantly. First class.

            (1 of 1 customers found this review helpful)

             
            5.0

            Keep coming back to this book

            By Curt

            from San Mateo, CA

            About Me Developer

            Verified Reviewer

            Pros

            • Timeless
            • Unmatched

            Cons

              Best Uses

              • Expert
              • Intermediate

              Comments about O'Reilly Media JavaScript Patterns:

              I keep coming back to this book. I use it as a reference these days. I've bought a number of newer JavaScript books looking for some additional insights, but I never find them and keep coming back here.

              (2 of 2 customers found this review helpful)

               
              5.0

              Great read

              By Callum Macrae

              from UK

              About Me Developer

              Verified Reviewer

              Pros

              • Accurate
              • Concise
              • Easy to understand
              • Helpful examples
              • Well-written

              Cons

                Best Uses

                • Intermediate
                • Student

                Comments about O'Reilly Media JavaScript Patterns:

                Great read, I learned a lot from this book. I do agree with Mike, though - the first half is definitely better than the second half.

                (1 of 3 customers found this review helpful)

                 
                3.0

                Fair read, although a bit unbalanced

                By Mike

                from Finland

                About Me Developer

                Verified Reviewer

                Pros

                • Accurate
                • Easy to understand
                • Useful as reference
                • Well-written

                Cons

                • Boring at times

                Best Uses

                  Comments about O'Reilly Media JavaScript Patterns:

                  Liked roughly the first half of it, but found the latter half somewhat boring. Reading long code samples like "this is how I would implement in JavaScript" makes for a good reference, but not really an entertaining read. On the other side, the "good to know" parts, conventions and tricks in the beginning were really useful.

                  All in all, well written and a decent read, but I for one got the feeling it's mostly an implementation reference about converting patterns from a language to another, without much consideration for the actual problems they solve.

                  (2 of 2 customers found this review helpful)

                   
                  4.0

                  Well done - Highly recommended

                  By Jon Frost

                  from Missouri

                  About Me Developer, Educator, SVG and Net developer

                  Pros

                  • Accurate
                  • Concise
                  • Easy to understand
                  • Helpful examples
                  • Well-written

                  Cons

                    Best Uses

                    • Intermediate
                    • Novice
                    • Student

                    Comments about O'Reilly Media JavaScript Patterns:

                    This book gets into the good stuff right away with well-written clear examples. I just wish there were a few more chapters with more real-world sample applications. Nice job.

                    (0 of 13 customers found this review helpful)

                     
                    3.0

                    Just found one error

                    By Aichi

                    from Berlin

                    Comments about O'Reilly Media JavaScript Patterns:

                    I did not read it but I discover one nasty bug in your code at page 75. IE test:

                    if (typeof document.attachEvent === 'function')

                    will never return true in IE because typeof will return 'object' instead of 'function'. Most common test is

                    if (!window.opera && window.attachEvent)

                    to be sure that we are using IE and not Opera and just test presence of attachEvent function by implicit type conversion.

                    (4 of 4 customers found this review helpful)

                     
                    5.0

                    Excellent for intermediate JavaScript

                    By bhofmann

                    from Exmouth, England

                    About Me Developer

                    Verified Reviewer

                    Pros

                    • Accurate
                    • Concise
                    • Easy to understand
                    • Helpful examples
                    • Well-written

                    Cons

                      Best Uses

                      • Intermediate
                      • Novice
                      • Student

                      Comments about O'Reilly Media JavaScript Patterns:

                      I've read through the book and thoroughly enjoyed the journey. It's not often a book is targeted so closely to the level I'm at when I start the book. I've learnt a lot from reading it, and it lives in my laptop bag now as a handy reference for when I need to look up a good way to implement something or just want to refresh my skills on closures when I've spent too long in C# code.

                      Stoyan explains the techniques and their pros and cons very well and gives concise working examples of the techniques or patterns.

                      The only thing I didn't like about the book was the end - I wish there wasn't one.

                      (4 of 8 customers found this review helpful)

                       
                      4.0

                      Excellent for professional developers

                      By ArpitNext

                      from New Delhi, India

                      About Me Developer

                      Verified Reviewer

                      Pros

                      • Accurate
                      • Easy to understand
                      • Helpful examples
                      • Well-written

                      Cons

                      • Not for beginners

                      Best Uses

                      • Expert
                      • Intermediate

                      Comments about O'Reilly Media JavaScript Patterns:

                      Learning these patterns and best practices will change the way you code. It will entirely transform you into a professional and experienced programmer.[@]

                      (7 of 7 customers found this review helpful)

                       
                      4.0

                      Lots of good examples

                      By Michael

                      from Olathe, KS

                      About Me Developer

                      Verified Reviewer

                      Pros

                      • Accurate
                      • Concise
                      • Easy to understand
                      • Helpful examples
                      • Well-written

                      Cons

                        Best Uses

                        • Expert
                        • Intermediate

                        Comments about O'Reilly Media JavaScript Patterns:

                        "JavaScript Patterns" takes the reader from a very basic understanding of JavaScript all the way to some very advanced language structures and patterns. The book uses lots of examples throughout, and it explains everything from best practices to how to implement advanced JavaScript data structures and patterns (singleton, function chaining, inheritance, callbacks, etc.). The book compares different patterns for achieving the same result throughout and draws conclusions about the best methods for different scenarios. There are plenty of code snippets demonstrating both good and bad examples that help to walk the reader throughout the intricacies of the language.

                        The book was very well written and answered all of the questions that I had pop to mind as I read it. It is written in a way that captures the readers attention while not being overly wordy or getting bogged down on unimportant topics. The vast number of code snippets and examples allow the reader to quickly go from even a rudimentary understanding of JavaScript to an expert level understanding. This book is more focused on learning how to implement advanced data structures and patterns in JavaScript, so it would be very helpful for someone working on JavaScript libraries like jQuery and others. However, if you are just planning to do some basic JavaScript for a website, this is not the right book for you.

                        Displaying reviews 1-10

                        Back to top

                         
                        Buy 2 Get 1 Free Free Shipping Guarantee
                        Buying Options
                        Immediate Access - Go Digital what's this?
                        Ebook: $23.99
                        Formats:  APK, DAISY, ePub, Mobi, PDF
                        Print & Ebook: $32.99
                        Print: $29.99

                        Available in Multiple Languages