You Don't Know JS: this & Object Prototypes
Publisher: O'Reilly Media
Final Release Date: July 2014
Pages: 174

No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. This concise, in-depth guide takes you inside JavaScript’s this structure and object prototypes. You’ll learn how they work and why they’re integral to behavior delegation—a design pattern in which objects are linked, rather than cloned.

Like other books in the “You Don’t Know JS” series, this and Object Prototypes dives into trickier parts of the language that many JavaScript programmers simply avoid. Armed with this knowledge, you can become a true JavaScript master.

With this book you will:

  • Explore how the this binding points to objects based on how the function is called
  • Look into the nature of JS objects and why you’d need to point to them
  • Learn how developers use the mixin pattern to fake classes in JS
  • Examine how JS’s prototype mechanism forms links between objects
  • Learn how to move from class/inheritance design to behavior delegation
  • Understand how the OLOO (objects-linked-to-other-objects) coding style naturally implements behavior delegation
Table of Contents
Product Details
About the Author
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
oreillyYou Don't Know JS: this & Object Prototypes
 
4.7

(based on 12 reviews)

Ratings Distribution

  • 5 Stars

     

    (10)

  • 4 Stars

     

    (1)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (1)

  • 1 Stars

     

    (0)

92%

of respondents would recommend this to a friend.

Pros

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

Cons

    Best Uses

    • Intermediate (10)
    • Expert (5)
    • Novice (4)
    • Student (4)
      • Reviewer Profile:
      • Developer (10)

    Reviewed by 12 customers

    Sort by

    Displaying reviews 1-10

    Back to top

    Previous | Next »

     
    5.0

    This is THE JS book

    By Arul

    from India

    Verified Reviewer

    Pros

    • Accurate
    • Easy to understand
    • Well-written

    Cons

      Best Uses

        Comments about oreilly You Don't Know JS: this & Object Prototypes:

        Makes lot of sense and everything clear

        (2 of 2 customers found this review helpful)

         
        5.0

        So happy to know much more... now!

        By laruiss

        from Paris, France

        About Me Developer

        Verified Buyer

        Pros

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

        Cons

          Best Uses

          • Expert
          • Intermediate

          Comments about oreilly You Don't Know JS: this & Object Prototypes:

          Really easy to read, just as in the first book (Scope & Closures), and pleasant to be taught quite complicated concepts with simplicity (and talent). I will surely buy the next one in the series... Ooops, already did!

          (2 of 2 customers found this review helpful)

           
          5.0

          More than just a javascript book...

          By The Gayngler

          from New York, NY

          About Me Developer

          Verified Buyer

          Pros

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

          Cons

            Best Uses

            • Expert
            • Intermediate
            • Novice
            • Student

            Comments about oreilly You Don't Know JS: this & Object Prototypes:

            'this and Object prototypes' is the second book in the 'You Don't know Javascript' book series. I would argue that this book probably could've served as the first book becuase this book challenges developers to actually re-consider the need of and use of the classical design patterns and assessing the benefits and drawbacks of it. In other words it challenges developers to actually be engineers instead of just developers.

            It is my opinion that I and other developers have been lazy in that we just accept classical software design as the way software should be developed without really thinking about what that actually means and the benefits and drawbacks of classical design patterns. Rather than fully embracing the benefit of behavior based delegation-oriented design in Javascript, developers have typically shoe-horned in the classical design patterns into Javascript.

            If you were even mildly disappointed in the first book in this series 'Scope and Closures', you will pleased to know that this book is head and shoulders better than the first book in this series and really is a shining example of what a good programming book should do is challenge you to think about software design in ways you had not previously really given much thought to.

            Gone is the somewhat pretentious tone of the previous book. Instead the author takes a different tone as he aims to teach developers think about the implications of classical and behavioral design patterns. It is as if Kyle got better at writing a book that people can read and learn from. There are plenty of code examples along with detailed explanations of what Javascript is actually doing behind the scenes. This may actually just be a good computer science book to have in general. I am very happy with what I have learned from this book.

            The last three chapters that compare classical vs behavior based design patterns in javascript really is worth the price of this book. This book is very well written and I think the last three chapters of this book has uses as a computer science topic in general and should not be limited to just a discussion about Javascript hence the 5 out of 5 stars I a giving it.

            (1 of 1 customers found this review helpful)

             
            4.0

            well to fill gaps

            By Laurent

            from Bordeaux

            About Me Developer

            Verified Buyer

            Pros

            • Easy to understand
            • Well-written

            Cons

              Best Uses

              • Intermediate

              Comments about oreilly You Don't Know JS: this & Object Prototypes:

              With this book, I have learned two things that I didn't understand in Js :
              - heritage whith prototype
              - this keyword

               
              5.0

              totally worth ur time and money

              By mihneasim

              from EU

              About Me Developer

              Verified Buyer

              Pros

              • Easy to understand
              • Helpful examples

              Cons

                Best Uses

                • Intermediate
                • Novice
                • Student

                Comments about oreilly You Don't Know JS: this & Object Prototypes:

                I like his explanations. Suitable for any js apprentice.

                (1 of 1 customers found this review helpful)

                 
                5.0

                Excellent coverage of a complex topic

                By Matthew

                from Des Moines, IA

                Verified Reviewer

                Pros

                • Concise
                • Helpful examples
                • Well-written

                Cons

                • Difficult to understand

                Best Uses

                • Expert
                • Intermediate

                Comments about oreilly You Don't Know JS: this & Object Prototypes:

                Kyle Simpson explains the semantics of using "this" in Javascript and why it is not the same as Java. The Javascript keyword "this" is often misunderstood. Many works treat it as the Javascript equivalent of Java's "this" or Python's "self," and while that understanding will lead to working programs in most cases, Simpson explains where that conception will break down in a way that many programmers will not be able to anticipate. He later discusses Javascript's prototypal inheritance and how it works different than typical inheritance designs.

                This text should not be a first introduction to the language and maybe not even a second or third. The topics covered are quite advanced and require a relatively high familiarity with Javascript to begin to understand. At times the text can be very confusing and require re-reading sections to fully grasp, however this is due to the complexity of the material covered and not due the author. The author's writing style is quite clear and his examples are well explained. Code samples are very short and to the point, not wasting space with unnecessary filler code which so many technical books do (pages of GUI code for explaining a simple input/output example for instance).

                This is the first example I have seen of covering these topics in this manner, and while at first I was unsure if they really warranted their own book, I did not realize how poorly I understood the semantics of "this." I would highly recommend the text to anybody who expects to do much work in Javascript, in particular in creating or working with frameworks, where a full knowledge of the topics covered could prove indispensible. After reading this text, I would be interested in reading the other texts in the series as well.

                (I received an electronic copy of the book as part of OReilly's reader review program.)

                (0 of 1 customers found this review helpful)

                 
                5.0

                Essential reading

                By Tom Dan

                from Ca

                About Me Developer

                Verified Buyer

                Pros

                • Accurate
                • Concise
                • Helpful examples
                • Well-written

                Cons

                  Best Uses

                  • Expert
                  • Intermediate

                  Comments about oreilly You Don't Know JS: this & Object Prototypes:

                  Great book, highly recommended.

                  (2 of 2 customers found this review helpful)

                   
                  5.0

                  great explanation

                  By Lewis

                  from Berkeley, CA

                  About Me Developer

                  Verified Buyer

                  Pros

                  • Concise
                  • Helpful examples

                  Cons

                  • Combative Tone

                  Best Uses

                  • Intermediate

                  Comments about oreilly You Don't Know JS: this & Object Prototypes:

                  I was pretty ignorant of inheritance and how 'this' works. This book got me up to speed, and now I'm using call, apply, etc in my code. The book has this idea called OLOO that I've found pretty useful, too.

                  (1 of 2 customers found this review helpful)

                   
                  5.0

                  Great Series Of Books

                  By Don

                  from Florida

                  About Me Designer, Developer

                  Verified Buyer

                  Pros

                  • Accurate
                  • Concise
                  • Well-written

                  Cons

                    Best Uses

                    • Expert
                    • Intermediate

                    Comments about oreilly You Don't Know JS: this & Object Prototypes:

                    This is the second in the series of "You Don't Know Js:". If you are interested in really knowing how JavaScript works, these books are for you.

                     
                    2.0

                    It is an Early Release, so maybe...

                    By Jamie R. Robillard Sr.

                    from Macon, GA

                    About Me Developer, Educator

                    Verified Buyer

                    Pros

                    • Well-written

                    Cons

                    • Not comprehensive enough
                    • Too basic
                    • Too many errors

                    Best Uses

                    • Novice
                    • Student

                    Comments about oreilly You Don't Know JS: this & Object Prototypes:

                    This is the first in a series and I am not impressed yet. Though it is the Early Release so maybe that is subject to change. I hate being to critical of an Early Release.

                    My major issues are:

                    1. The cost is too high for a book with less than 150 pages. 150 pages is a pamphlet not a book and with the 50% off for pre-release cost being at $18.00. I can guarantee you, no matter who you are, No 150 page book is worth $36.00. I feel a bit cheated $18.00.

                    2. In the six chapters the book does have most of it is the author defending their views. I get that making a contrast between the right and wrong way of doing it is a valid way of teaching. Though one would expect a couple of sentences on why it is the wrong way and many paragraphs on the right way. This book takes and inverse approach to that and dwells on many example of the wrong way with only a brief touching on the right way. If you do not already know the wrong way to do it, you will by the time you finish this book, I can not really say that about the right way.

                    3. The source example might as well have been Pseudo code or BNF. Hey I like Kernighan and Ritchie also, and I will probably always covet my 1st edition K&R C programming book. Though it has not been since then that I have seen such horrible use of snippets for code examples. Furthermore code snippets that cannot even easily be used and worked with in a real life scenario that would make sense in a practical way. Yes I understood the snippets. Though I did not get anywhere near as much from the code snippets as I would have real code examples. Which are the standard today, as far as I am concerned at least. Now, if we could get like a few snippets to clarify a point and then use those snippets in a practical example. Then make each chapter example part of a book project, and each book project part of the series project then I would be much more impressed, I would be waiting for the next book in the series, even if it was over priced. Book projects and complete examples are more than just a trend, they have been proven to be the most effective way to teach. I strongly advocate their use in all technical books. Things we can use, we learn. Something that just makes a point, well we might get the point at the moment, but that knowledge with no practical usage tends to drift away quickly. I was also a bit disappointed that the only real practical example in the book required me to setup my server with code to respond to the book example. The example in itself should be complete, or at very least the server side should have been available for download. Especially considering the fact that the server side implementation was way beyond this book.

                    4. Besides practical code examples, increasing the size of the book, and the amount of useful content, I feel the author has great potential. They just need a bit more focus on the subject on hand. They ignored the fact that teaching proper use of Prototypical programming was the focus of this book. Javascript uses a Prototypical Object Oriented Paradigm (methodology), and the author was completely correct in the assessment that trying to force Javascript to be Traditional Class based OO is not practical or advisable. I was hoping this book would give many prototypical examples so I could refer it to friends and students. Rather than highlighting Prototypical OO the author chose to diverge into I guess what they consider to be their own self ordained Paradigm OLOO {Objects Linked to Other Objects}. Though it is a fairly decent explanation of how Prototypal OO works the author is obsessed with establishing this as a methodology in itself, rather than an explanation of how Prototypal works? The author also mistakenly referred to OO, Class Base and Prototypal as a Design Pattern? That is not a commonly used in descriptions of OO. The Design Pattern would be MVC (Model-View-Control) MVP (Model-Presenter-View) and such that we can study in the classic 'Design Patterns - Elements of Reusable Object Oriented Software' - by Erich Gamma, Richard Helm, Ralph Johnso, and John Vlissides. What the author is referring to is the Programming Methodology or commonly referred to as the Programming Paradigm of the language. Though we all know that Bjarne Stroustrup prefers Programming Methodology and considers Paradigm to be uptight, I am aimable to either. Though I am not so amiable as to allow Paradigm and Design Pattern to be synonymous I think that breaks some boundaries that will cause problems in visualization and comprehension for the student in future studies. Your opinion on this may vary, I think the majority of Computer Science would favour them being separate topics and not synonymous though.

                    I do feel that the author could be a great author based on the fact that the book was very well written. The content was just very lacking. Now if the author could get the content up to their level of writing I would have no issue at all referring this book.

                    I cannot wait to see revisions of this book as they are released, I hope there will be a major rewrite and my next review will only be ravings on this great author and the quality of their book, until then, I would just say to the author "Keep trying, you will get there."

                    Sincerely,
                    Jamie R. Robillard Sr.

                    Displaying reviews 1-10

                    Back to top

                    Previous | Next »

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