Jump to ratings and reviews
Rate this book

You Don't Know JS #4

You Don't Know JS: Types & Grammar

Rate this book
No matter how much experience you have with JavaScript, odds are you don't fully understand the language. As part of the "You Don't Know JS" series, this compact guide explores JavaScript types in greater depth than previous treatments, defining the problems of coercion, demonstrating why types work, and showing developers how to take advantage of those features.

The type system in JavaScript is subject to several misconceptions. Many developers believe that JavaScript has no types, but that's not the case. JavaScript uses a number of types behind the scenes, and has a sophisticated system of implicit and explicit coercion between the various types. This book gives you the complete story.

Like other books in this series, "You Don't Know JS: Types & Grammar" dives into trickier parts of the language that many JavaScript programmers simply avoid. Armed with this knowledge, you can achieve true JavaScript mastery.

182 pages, Paperback

First published August 25, 2014

109 people are currently reading
1177 people want to read

About the author

Kyle Simpson

37 books360 followers
Kyle Simpson is an Open Web Evangelist from Austin, TX, who's passionate about all things JavaScript. He's an author, workshop trainer, tech speaker, and OSS contributor/leader.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
439 (58%)
4 stars
240 (32%)
3 stars
59 (7%)
2 stars
9 (1%)
1 star
1 (<1%)
Displaying 1 - 27 of 27 reviews
Profile Image for Helen.
422 reviews97 followers
August 17, 2017
Essential reading for anyone working with JavaScript.

Beginners will get a good grounding in the basics of the language types and grammar and it goes into enough detail for experts to learn something too.

I think this is the third or fourth book in the series, but in my opinion, it should be the second. There's nothing in here that you need the second or third books (Scope and Closure, and this & Object Prototypes) to understand.

It's all quite basic, but very important if you want to really understand what's actually happening when your code runs.
42 reviews1 follower
February 17, 2017
Still an important read but less mind-blowing and more frustrating than the other books due to the persnickety nature of coercion in JS. Kyle's ardent defense of the language is no less admirable but slightly more difficult to stomach here!
Profile Image for Hưng Đặng.
129 reviews71 followers
January 22, 2019
The first part of this book is about data types and some quirks of the language with data type. Let me give an evil example:
`0.1 + 0.2 === 0.3 // false`
To be able to understand this peculiarity, we must dig somewhat deeper into floating-point value which IEEE 754 (I can't stand it the first time I heard this name, now I come to term with it) document would mention.
Each data types has their own weirdness that I would not spoil it here.
One thing I like about the book is its recommendations about best practices. I have hightlighted them all and maybe I will go back to them from time to time.
In my opinion, coercion is another big thing in the book. The author argues that there are certain cases that implicit coercion would be useful but I don't think so personally. I value readable code and I don't have that much experience to distinguish the right situations for the tool.
"==" is no easy tool and its possiblity to create bugs is terrifying. Despite of the fact that the author encourages not to shun this thing, I think I may subconciously avoid using or use it with great caution.
Although the title of the book has "Grammar", I don't think it plays that significant role except its "Function Arguments" chapter which is a good one.
One thing that I don't like about this book is the example code is not very close to my day-to-day practice. Perhaps it is a good thing that it makes me even more curious about the last book in the series "ES6 and beyond".
Profile Image for Hatem.
24 reviews1 follower
May 23, 2019
This book is not as interesting or intriguing as other books in the series because it goes through the basic stuff then it's basically a list of Gotchas and quirks in the language logic. I gave it 5 stars because Kyle's explanations and examples are amazing even if the material itself is dull.
Profile Image for Jon Jones.
88 reviews1 follower
December 25, 2019
All books in this series are essential reads of any Javascript developer. Types are the basic building block of every programming language, so understanding them properly is key. The part of the book I learn the most from was around coercion, how it works and the difference between implicit and explicit conversations. The bok has definitely changed the way I think about some of the 'bad patterns' other books have recommended avoiding completely.
Profile Image for Prakash.
165 reviews97 followers
December 1, 2017
Excellent and comprehensive.

Although the content isn't organized in a strict way. I would also urge people not to follow author's advices always in terms of style (=== vs ==) and make their own opinions. Also the authors sometimes is too defensive about JS.

But definitely recommended. Did I mention it is free?
19 reviews
Read
February 27, 2020
This is a usefull book which helps you to understand the type system lying in foundation of the language. You will understand what a mess js types are but you'll be able to navigate through that mess easyly. There is a side-effect: you may become resistant to JS type coersion WTF jokes because coresion rules will become straightforward and reasonable for you.
Profile Image for Vibhor Rawal.
55 reviews7 followers
January 6, 2022
This one was better than last book in series. Kyle added helpful gotchas and how to's code. There was also much clearer why use this feature/why not. This did not feel as polarising as last book. The == vs === guide is especially helpful for someone like me who was told to never use == by so many articles, seniors.
Profile Image for Yanjia Li.
38 reviews3 followers
June 22, 2017
Solid and well rounded introduction of low level JS

Literally JavaScript: The Bad Part. However, it helps you understand how JS works underneath those fancy ES5/6/7 syntax. Recommend for experienced JS developers.
Profile Image for Ryan Day.
31 reviews
July 12, 2017
I've never read a book about JavaScript like this. Simpson puts aside everything you've learned about JavaScript over the years and digs into the spec to find out how the language really works. You Don't Know JS makes JavaScript feel like a new and exciting language again.
50 reviews10 followers
October 18, 2017
Seriously Guys, If you want to learn Javascript this book-series is the best ......
Stop whatever you are doing and read this book if you haven't yet.
Profile Image for Mark.
143 reviews6 followers
May 23, 2018
Solid overview on the language semantics and grammar. Sometimes a lot of this goes over my head, but I came out with a lot to think about. Overall a solid read!
3 reviews2 followers
January 9, 2019
very good examples and easy pacing for people who are slow to understand concepts.
Profile Image for Anh Trinh.
53 reviews1 follower
April 8, 2020
Many helpful information, especially Natives and Coercion.
Profile Image for Marc Udoff.
153 reviews7 followers
November 25, 2015
A good read on JS to understand each of the primitive types, boxing and unboxing, comparison (== vs. ===), and other got you's of the language. Geared towards an intermediate JS programmer more than anyone else. Good to have read once.
Profile Image for Franco Risso.
40 reviews2 followers
June 15, 2016
Exceptionally well explained book about the nuances of JS for types and grammar. You can learn here that using implicit coercion is not as bad as you can imagine right now, and remove that lint rule of forcing strict comparison from your project!
Profile Image for Victor.
355 reviews6 followers
January 30, 2017
This book is very in-depth to the workings of type coercion and the grammar of javascript. However, it does not go too far to the low level implementation of javascript. Just explained the different standards and how they affect the usage of the language.
23 reviews1 follower
January 23, 2016
clarifies trivial misconceptions about JS (especially with castings, operator precedence, etc)
Profile Image for Eder Sanchez.
57 reviews6 followers
May 27, 2016
Como en todos sus libros hay gotchas interesantes y explicaciones detalladas de los mecanismos del lenguaje, pero la actitud del autor me hace querer odiarlo.
Displaying 1 - 27 of 27 reviews

Can't find what you're looking for?

Get help and learn more about the design.