

📘 Crack the code with JavaScript's best parts — don’t get left behind!
JavaScript: The Good Parts by Douglas Crockford is a definitive guide that distills JavaScript into its most reliable and elegant features. Targeted at intermediate programmers, it clarifies the language’s confusing prototype inheritance model, exposes common traps like misuse of 'new', and promotes best practices for writing clean, maintainable code. This book is a critical resource for developers serious about mastering JavaScript’s core, offering insights not found in typical programming books.



















| Best Sellers Rank | #291,302 in Books ( See Top 100 in Books ) #44 in JavaScript Programming (Books) #266 in Software Development (Books) #320 in Internet & Telecommunications |
| Customer Reviews | 4.4 out of 5 stars 1,463 Reviews |
F**S
Wish I had this book when I first started Javascript
Do you struggle when creating objects in Javascript? Do you find the syntax to be non-intuitive and frustrating? Do you know the difference between using a function as an object vs using an object literal? Do you know how using object literals can simplify your code and create something similar to namespaces? Do you know how to augment the type system -- for example, if wanted all strings to have a trim() method? Do you know why the "new" statement is so dangerous? Do you know an alternative that eliminates the use of "new" entirely? These are some of the topics that the book touches upon. This book is aimed at someone with intermediate programming experience that wants to know the best way to create and use objects, arrays, types, etc. Crockford takes his experience with Javascript to show you best practices coding techniques and styles to use with Javascript. In addition, the book provides insights into what makes Javascript so confusing and what can be done about it. You might ask "Isn't this stuff already covered in other books that I have?" The answer is no. For one, most other books use a psuedo-classical coding style (see below) to explain objects that is a source of confusion. Javascript can be very confusing, especially for programmers who have extensive experience in other C-based languages (like myself). Writing good Javascript that uses objects, methods, etc. is hard. In Javascript, if you want to create objects, use inheritance and create methods, you have several different ways to write your code and it's difficult to know what the strengths and weaknesses of each are. Crockford explains the problem plainly. Other C-based languages use class inheritance (Crockford calls this classical inheritance). Javascript, on the other hand, is the only popular language that uses prototype inheritance, which does not have classes. However, the syntax which Javascript uses to create object is Java-like (Crockford calls this pseudo-classical syntax). It's confusing, because it keeps you in a class-based frame of mind while working in a language that has no concept of classes. Clarifying what's going on with the object model is the best part of this book. Crockford also explains other parts of Javascript that can be problematic and the techniques that he prefers for handling them. I don't necessarily agree with all of them, but the important thing is that he explains his reasoning. To effectively learn Javascript, I recommend that you buy 1) a book that covers the details of the language and can be used as a reference (e.g. Javascript, the Definitive Guide) and 2) Crockford's book. Advanced programmers might also enjoy Pro Javascript Design Patterns, which shows a number of ways to combine Javascript with some of the GoF patterns. I would avoid any cookbook style books on Javascript, because you're better off using YUI, JQuery or one of the other Javascript libraries than writing your own drag-and-drops, calendars, etc. There are a series of Yahoo! videos by Crockford that mirror the material in this book and can be found as podcasts under YUI Theater. They contain nearly all of the material in the book and probably a little more. Those videos are: - Douglas Crockford/An Inconvenient API: The Theory of the DOM (3 parts) - Douglas Crockford/The JavaScript Programming Language (4 parts) - Douglas Crockford/Advanced JavaScript (3 parts) - Douglas Crockford/Javascript The Good Parts
J**Y
Excellent book - for the right audience
I just finished this book. It's relatively short but you have to invest a lot of hours to properly absorb it. I think I'm going to need one more pass. I do not understand the majority of complaints. Some compare Crockford to "the most boring professor you ever had", others said the information was poorly organized and not written very well. Others complained about his ego getting in the way. I, for one, found it to be very interesting and useful. Parts of it were a struggle to get through (and I've been a C coder for 20+ years) but mental challenges are a software engineer's specialty. In my opinion, none of the complaints are completely true, assuming you are the right audience. This book is NOT for beginners. If you are relatively new to Javascript, it will definitely be useful, but if you are new to programming entirely, this book is not for you. This is a more academic book that gives you a peek behind the scenes to the inner workings of the Javascript language. It is more comparable to K&R's book for C Programmers, but not as complete (just the "good" and "awful" parts!). It is a book about the Javascript LANGUAGE. It is NOT a book on web programming. It will NOT teach you anything about HTML, or the DOM, or how to put little fiddlly-bits on the screen, or how to work out game physics, or how to use any HTML-specific components. It is a book on the constructs of Javascript, plain and simple. It should NEVER be the only book on Javascript you would own, but if you are serious about Javascript, it should definitely be in your library. I don't think you can be a Javascript master without this book. My minor grievances are mostly limited to subjective areas where I disagree with him: 1) He states his opinion absolutely, more so in the first part of the book. I prefer a less forceful approach that presents the arguments and lets you decide for yourself. However, I do not feel he went overboard in this regard as some did - I suspect they didn't get very far into the book. 2) While I completely understand the Javascript bugaboo that makes a case for mis-aligned curly braces (K&R style). I cannot get myself to follow this convention (except in a few areas where I make exceptions) To me, code is SO much easier to follow when all blocks are aligned. I will heed his advice and avoid the lurking JS bug, but I will not fully convert to misaligned braces. I resent that his JSLint tool generates hundreds of errors in my code because of this - but fortunately, there's an option to turn it off. 3) When he digs into some of the JS-specific patterns that aren't familiar to non-JS programmers, I wish he would add a disclaimer along the lines of "while this is a powerful tool, understand that depending on such patterns may make the code more difficult to maintain by others less trained in the specifics of Javascript. Or at least comment vigorously." I am a firm believer in "clarity over cleverness" in shared code. 4) In some of the trickier subjects, a few more examples would makes things easier to comprehend. I've never really used Regular Expressions before, and the chapter left my head swimming, and I felt the explanation of the various components of the expressions could have been better. But these are not major grievances, and I whole-heartily recommend this book for the intermediate Javascript user or the novice JS user who has a solid background in general programming language constructs.
L**E
Great book on JS
I am a fairly new programmer, so I do not know how my review will really help anyone. However this book took my understanding of Javascript to the next level. I went through the book, some of the content in the book is probably stuff you'll probably not utilize much at all, however it is comforting to have a reference at hand that can give you examples and a brief summation (other than MDN) to help you with your understanding of the book. This book would pair nicely with Beautiful Code. The author mentions his article in the book, in that article he also looks at JS's good parts but in a simplified way. The biggest thing to note when going into this book: the author emphasizes the importance of objects in JS, the use of functions and variables to manage objects and efficiently create JS programs. He also gives a section on the terrible parts of JS, just for one to understand and avoid them. All-in-all, it is a compact good book, a bit succinct on the more complex subjects. However go to stackoverflow and search/ask some questions if you are confused. In my opinion the best chapters: 2-3. Intermingling this with actual coding on your part (utilizing JSbin or JSfiddle, etc) will help you get the most out of understanding some of the behaviors of the language. Pretty much utilizing objects is your best bet for creating efficient and usable JS code. 6 pretty much sums why arrays are inefficient in JS. 4-5, 8. This helps one understand the importance of functions in JS. Also there is a good reference for some of the more used methods that are tied to the prototypes objects. 10. It is short and does not teach you anything about JS, but pretty much sums why adding every single library you can is probably a terrible idea.
I**I
Do proper OO with JavaScript by tapping into its Functional core
Java is an Object-Oriented language; JavaScript ain't. JavaScript provides no integrated support of type-inheritance, encapsulation or polymorphism - the cornerstones of the Object Oriented paradigm. However, OO programming can be SIMULATED in JavaScript. There's more than one way to achieve this effect. In this short and illuminating title, Crawford delineates one such way, which relies on some peculiar features JavaScript has in common with functional programming languages, such as "Scheme". (Study the ASP.NET AJAX framework's client side, for a completely different way to go about it. Gallo et al.'s "ASP.NET AJAX in Action" explores this framework brilliantly). In parallel, this book also serves as a well-reasoned best-practices manual for writing good JavaScript code (a la Crawford...). Crawford's simultaneously a fierce critic, and a starry-eyed lover of the language. Her smiles, her frowns, her ups, her downs are, clearly, second nature to him, and, like a great tour guide, he'll walk you through the grotesque and the beautiful of this strange, and, oddly, remarkably popular, programming language. This book is neither an introduction to JavaScript nor a reference thereto. It's certainly not about DOM scripting. The novice JavaScripter would benefit little from it, and, in fact, might find it utterly disheartening, due to Crawford's explicit, harsh criticism. Turn, instead, to the first and third parts of Flanagan's excellent "JavaScript, The Definitive Guide". In the appendices of this books, you'll find a superbly succinct-yet-exhaustive descrpition of the popular JSON data-interchange format, of which Crawford himself is the designer. A complete listing of a JSON parser written in JavaScript is also available for you to delight in.
B**Z
Small, but dense
When it comes to JavaScript, Douglas Crockford is "The Man". When it comes to browsers, JavaScript is "The Language". "JavaScript: The Good Parts" should be read - and comprehended - by every web developer, regardless of their programming proficiency. This slim volume contains the essence of the JavaScript language. It is not concerned with the inner workings of JavaScript, nor is it a "Learn JavaScript in a Fortnight" type of book. It is more a meta-JavaScript guide of style, pointing out features and usage not available elsewhere, except perhaps at his website, "Douglas Crockford's Wrrrld Wide Web" ([...] Those new to the language may find this book to be like James Joyce's "Ulysses" - that is, incomprehensible. The use of closures, self-reference and passing functions as parameters to other functions takes some time to grasp fully. The end result is worth the time invested: you will be a better programmer for having digested the information provided by Mr. Crockford. Heck, you will be a better programmer even if you don't grok everything put forth in the book. As the inventor and promoter of JSON, short for "JavaScript Object Notation", Mr. Crockford deserves much praise. JSON is a data interchange format made up of a JavaScript object. There are implementations of JSON for many other languages (visit the aforementioned web site for details). While not strictly a replacement for XML, JSON is as readable, requires no external parser to implement and can be operated on directly in any browser that supports JavaScript, and the major ones do. I must admit, I am an addicted JavaScript programmer. I found Douglas Crockford many years ago, and while he does not know me, he has mentored me and brought forth a deeper understanding of JavaScript that also applies to programming in general. Comments, the use of whitespace, blank lines; these are things not often found in a web application. I strive to always be a Good Programmer, and when I find myself slipping into old, bad habits, now I have a book to lift my spirits and show me the way. Yes, "JavaScript: The Good Parts" is that good.
N**S
Thorough and thought-provoking discussion of JavaScript
At 145 pages, "JavaScript: The Good Parts" is a quick read packed with lots of information. Douglas Crockford (author) claims that JavaScript is littered with several poor features, and that using a subset of the language (i.e. the "good parts") will allow a JavaScript programmer to write better programs. He provides a thorough overview and discussion of his claim, and demonstrates his expert-level understanding of the language. New concepts are presented with the aid of "railroad" diagrams. These were a bit cryptic at first, but easy to decipher after some study. In some areas, performance implications of using the "good" parts versus the "bad" parts (or vice versa) were either skimmed over or skipped. I would have liked to see more analysis and benchmarking on that front. As far as code examples are concerned, this book provides plenty of commented and explained snippets. Also, some third party tools are described that can help a JavaScript developer apply the concepts discussed in the book. A good example of this is an Appendix dedicated to JSLint. Note: I would highly recommend the Appendices, they are just as informative as the chapters. This book is most effective when studied by a programmer that is familiar with JavaScript at an intermediate level (or higher), or a programmer that is experienced in another high-level language. Crockford's writing style is clear and concise, spritzed with some lighthearted humor. Also, the Shakespeare quotes at the beginning of every chapter were a nice touch. All in all, this book is worth the read. It is quick and thought-provoking, as well as a valuable addition to the bookshelf.
A**S
At Long Last, A Serious Javascript Book
For about as long as it's been about, Javascript has endured a plague of poorly written and presented books. "A Million and One Ways to Write a Rollover." Many books will treat writing a function as an advanced move. It is left as an exercise for the reader how to manage ones code when the scale surpasses the trivial. Douglas Crockford, who works at Yahoo, is unable to leave these questions in the realm of the intellectual, and he is in growing company. The era of large Javascript applications is upon us. By large, I mean applications that are mostly javascript, rather than HTML documents with a splash of code. This is more than mere AJAX. This is true application development, and with the scale must come application scale rigor. It is to the problems of serious application developers that Crockford addresses the book. This is *not* an introductory book. It is generally assumed that the reader knows what the building blocks are. Instead, Crockford focuses on issues such as organization, error avoidance, and writing code touched by many developers. More importantly, Crockford expresses opinions. Technology as a field is never short on opinion, but technology books are a wasteland. Good luck finding a volume that spends much time at all criticizing its subject matter. Crockford pulls no punches. If he doesn't care for a given design decision, he says as much. It is, in a word, refreshing. Would that more books offered such candor. Even if you disagree with Crockford's answers, the exercise of working through his arguments will teach you to ask better questions. In exchange, you will learn about some of the more powerful but under-used aspects of Javascript, such as closures and first class functions. Furthermore, Crockford's detailed descriptions will give you clearer insight into exactly how the language really works. In sum, Javascript: The Good Parts is the sort of book that can move you to the next level in your javascript development. Thank the gods the age of platonic, useless JS books is behind us.
B**P
Some good data, but scattered and inconsistent, unclear who it's written for.
I'm a long-time C, C++, and Java programmer (videogames, predominantly) learning Javascript to do some web work, so I picked up this book because the reviews were good and the notion appealed to me - learn the subset of this rather sloppy language that you can use as a good language. My TL;DR version of the review: this book is a hodgepodge of different information about the language, but some of it is so complicated it'll go immediately over the heads of new programmers, and then some of it is so mundane (even pedantic, talking about very specific aspects of coding styles) it felt goofy and out of place. It seems to me that any specific individual reading this book won't really find more than one or two chapters very relevant. I give it 3 stars because the useful parts were useful to me, but I skimmed and ignored 80+% of the book. Crockford's writing is personable and clear, and the book's organization is straightforward. Here's my chapter-by-chapter breakdown. Note that this is all from my perspective, what I personally found useful or not, but my point is, while other readers will certainly disagree with me about what was useful, I have trouble imagining any one person finding more than about 20% of the book useful. Chapter 1 is an introduction and high-level explanation of the point of the book. Chapter 2 covers basic grammar and the likes, which was helpful though it's not aimed at any particular familiarity with other languages so it's trying to be comprehensive, which meant that as an experienced programmer in other languages I had to skim it and just look for differences with what I'm already used to. Chapters 3 and 4 were the most useful parts of the book for me: the section on objects and functions, data scoping and closure, which really takes a new way of thinking if, like me, you have a lot of experience with languages without closure and anonymous functions and the like. Crockford does a good job of explaining this and giving relevant examples. This section was 20% of the book and was the only section I found really useful. Chapter 5 covers inheritance. He presents two methods, one using new and constructors like one of the languages I'm more used to, and gives a couple reasons to avoid this, and then digs into the prototypal method, which is unfamiliar to me. The problem is that he uses totally abstract examples here - classes representing animals and methods that return their names or the noises they make - and it was very hard for me to relate it to any actual application, and since the prototypal style is a fundamentally different paradigm I don't feel like I really grasped it from his writing. Since he builds a framework of extension methods throughout the book, once I started to lost his train of logic I was utterly lost. And the "meta" nature of javascript, assigning functions to methods that return other functions that wrap functions, I found it easy to get lost. Chapter 6 covers arrays. If you've used scripting languages this stuff is very simplistic, a stark change from Chapter 5, which is quite sophisticated. Again, my point here - I don't know who would simultaneously understand Chapter 5 and still find anything in Chapter 6 useful. Chapter 7 is a significant change of direction; it's a long chapter on regular expressions which I skimmed very quickly since I know them from using perl. This part seemed odd, since regular expressions are common to several languages, and there's nothing particularly unique about javascript's usage of them. It felt a bit misplaced in this book. Certainly they're an important part of the language, but again made me wonder: who's the book for? Chapter 8 is a reference for core API functionality and his extension methods; this feels like stuff I'd just google while coding, not terribly valuable to me personally. Chapter 9 is a diversion on coding style, and felt wildly out of place and kind of insulting: if this book is for a seasoned programmer this is just going to trigger unpleasant flashbacks to arguments you had back when you were a junior programmer. If you're a new programmer and this stuff is news to you, other chapters in the book are going to be utterly incomprehensible to you. Chapter 10, "The Beautiful Parts," is all of a page long, but a nice summary of the good aspects of the language. Appendices A and B cover some of the "Awful & Bad Parts" of javascript in detail; this was the second-most interesting part of the book to me, though it's brief and you've picked it up if you read the rest of the book. Still, definitely value here. Though worth noting: he inserts some more editorializing here, ala Chapter 9 - he calls out some things that aren't specific to javascript, like switch statement fallthrough, as bad parts, which I found annoying. Stick to aspects unique to javascript and point out real dangers instead of offering advice on very broad aspects of coding style, I kept thinking. Appendix C is about JSLint, the lint for javascript. It was useful only in the sense that I didn't know JSLint existed, and now I do, but then he gives a long swath of what amounts to JSLint documentation, which I have to imagine exists on the JSLint site, and felt like filler. Appendix D is about JSON and just some reference information about the format. Maybe useful, but no authorial insight, just docs. Overall, glad I read it, but I was pretty underwhelmed given the generally great reviews of the book on here.
Trustpilot
2 weeks ago
1 day ago