loading...

What I have learned from the book "Javascript Grammar II" by @js_tut

veslav3 profile image Roy Honders Updated on ・4 min read

With this post you will able be to evaluate whether or not you should pickup or read the book yourself.
Since I already have some experience with Javascript, you can use my blog post to evaluate the amount of new information someone with experience with Javascript can acquire from this book.
If everything I'm saying is new to you, please read the book for yourself.
If you know half of these things you probably know enough already.

book cover

First of all I want to thank Greg Sidelnikov (@js_tut ) for putting this amazing book out there, free of charge. You can find his tweet about it right here:

So what have I learned from his book?

First of all I have learned that Javascript has a new language version ECMAScript 2019 (ES10). This means that they have added some new features to the language.

Next to that I have learned that there is a copy function in the chrome devtools. This can copy objects to your clipboard which could be really useful for constructing automated tests.

Also learned that the JSON format expects double quotes and with single quotes it doesn't behave well (although from my experience it is possible to stringify objects with single quotes).

In Javascript each object has it's own name that identifies the object. This way two identical objects could be separated.

In order to delete a property on an object you can use the "delete" keyword.

Destructuring in ES6 is also possible for arrays, for example:

[a, b] = [1, 10]
// a = 1, b = 10

Declaring a variable using var attaches the variable to the window object. But using let doesn't do that.

Closures are functions inside other functions that will immediately be invoked inside the top level function. This way you can execute multiple functions at once.

Closures can also be used as function constructors.

You can get the amount of parameters in a function from the length property on the function object:

function x(param1, param2) {
}
console.log(x.length) // logs the value: 2

In a loop you can skip a step by using the continue keyword.

In Javascript statements, for example a for loop can be labeled in order to refer to them when using the break or continue keywords.

Array.some & Array.every are useful functions for evaluating the contents of an array.

Reducers (reduce functions) have to return a value of the same type as the input. For example if numbers are inputted, numbers have to be returned. Not let's say strings or booleans.

Iterators can be converted to an array using the spread operator.

Writing your own code for solving a problem is always a good idea, because then you will be thinking for yourself instead of relying on someone else's partial solution to your problem. Problem solving is your job.

Abstraction is your best friend.

Abstraction will help you a ton when programming in general, but it also applies to Javascript.

When you declare a function it will have a parameters property. When you declare an arrow function (() => {}) it won't have the parameters property.

Arrow functions inherit the lexical scope of the code when using the this keyword. This can be useful when you need to use an object reference instead of a reference to the window object.

In Javascript functions are the constructors of all object types. Even for functions themselves.

requestAnimationFrame() is useful to make animations appear smoother.

Last bits of the book

In the end, the book talks a lot about object oriented principles which I already know a ton about because of my education. That's why I completely skipped that part of the book, since I would have to filter out almost everything that I knew already. So I cannot judge that part of the book on it's contents, you would have to read it for yourself.

The book also seems to stress the importance about knowing the inner workings of Javascript and how topics like the event loop are often asked as interview questions. This is because the deeper understanding of a language will separate the beginners from the professionals and this knowledge will allow for more efficiënt programs and websites being built.

Conclusion

Although you might have learned something new from this list of new things that I have learned, you might not have learned everything that is available in the book. It may also be possible that after reading this, you are lacking the context that is given in the book about each statement that I talked about. Then it's a good idea to check out the book for yourself.

Note: this is my first post on this platform and I might have made a minor error in this post. I am open to feedback and am willing to correct potential mistakes in order to improve the quality of the post.

If you liked my content, be sure to follow me on Twitter!

Discussion

pic
Editor guide
Collapse
thunderfury1208 profile image
Gilbert Martinez

I have actually thought about buying this book as well. I follow this man on Twitter and love his posts. I saw many books the dark and then this one as I am seeking color paperback. Is this the book you'd recommend?

Collapse
veslav3 profile image
Roy Honders Author

I only recommend if you know only about half of javascript at the moment. If you know like 60% of the language, it might not be worth it.

Collapse
discreetsoft profile image
discreet soft

good awesome information, thanks

yaser
Discreet Soft

Collapse
dasmurphy profile image
murphy

You need to try this in Chrome ;)

((a) => {console.log(a)})(1)

And you have parameters on anonymous functions.

Collapse
veslav3 profile image
Roy Honders Author

Wow, going out of your way don't you? :D