I’m writing JavaScript for a long time, and one of the first things that I learned is to use === (triple equals) instead of == (double equals).
I think the comma operator in JavaScript is underestimated. The popular perception is that we use the comma to separate function arguments or items in an array. However, there is another use case.
Back in the days when I started reading about the new features of JavaScript, I was the most excited about the spread operator. It allows us to expand iterable (or strings) in various places.
I first saw destructuring in some other language. It took me some time to understand it, but once I got the idea, I couldn't stop thinking how nice will be to have it in JavaScript.
My "favorite" error while I'm doing something with JavaScript is "Cannot read properties of undefined". Optional chaining could address those cases.
In programming, there is the phrase "passing a variable". That is the moment when we call a function with a given parameter. In some languages ...
Very often, we have to transform objects from one shape to another. My favorite tool for such transformations is the `reduce` function
The topic of asynchrony in JavaScript is huge. That is because the language offers many mechanisms for handling asynchronous operations. Over the years, those mechanisms change.
The iterable protocol is underrated. I don't see people using it, which makes me sad because it's a wonderful instrument.
Like the iterable protocol, using generators in JavaScript is not very popular. The community is not betting a lot on this API. I think thought ...
Very often, we need to look inside objects. One of my favorite ways to print an object is to use `JSON.stringify` API.
There are some APIs that I use frequently. `Object.assign` is one of them. For me, the use case is almost always constructing a new object by merging various properties.
Like most programming languages JavaScript supports regular expressions. I'm writing software for more than 15 years, and I've never been good with this...
Some time ago, we couldn't write multiline strings in JavaScript. We had to concatenate one-liners. Then the template literal was introduced. Suddenly our life became easier.
I saw the first article about responsive design in 2010 (by Ethan Marcotte). Since then, the Web has evolved, and so ...
I find it very interesting how we start forgetting stuff when technology evolves. One of these things is the event delegation.
There is one thing that developers forget very often - error handling.
I remember when copying to a clipboard was done via embedding a small Flash app. Nowadays, we have an API for this.
Early in this book, we mentioned the async/await syntax. I remember the time when this API came to the language. Our code became ...
Sometimes I like to solve problems that libraries already solve. One of those problems is handling multiple async operations one after the other.
There are different types of scope in JavaScript. One of them is the module scope. A variable at the top of the file falls into that scope.
Did you ever wonder how the call-to-action widgets work? You know, those little buttons for sharing content on social networks.
Earlier in this book, we learned about the destructuring assignment. An interesting use case of this feature is that it allows us to remove a field from an object.
As we know, JavaScript is not a strictly typed language. We don't have types by default. That is why a big part of the community started using alternatives like ...
It's funny how in the past we had to write a lot of things alone. There was no NPM or GitHub. We had to write our own loader.
There are tons of different opinions on what is a good code. For me, the best answer is, "Good code is the one that I and my teammates understand".
Even though I'm writing JavaScript for many years, I'm still learning. And I'm getting surprised by simple things. It could be a pattern or just a style of writing.
JavaScript by default has no type definitions. It has been like that since day one. Today we can solve that by using languages like TypeScript.
There is always one chapter for the `this` keyword in every JavaScript book or course.
At the job interviews for JavaScript developers, two questions are almost always asked - the first one is about the `this` keyword (covered in the previous chapter), and the other one is about scope.
We saw the four different types of scope. I want to share a small tip regarding the block scope. And precisely when we need to create it on purpose.
When we know what scope is, it's time to explore the `call`, `apply`, and `bind` methods.
Back in the days when the Web was all made of jQuery, we were constantly using a pattern - function (or method) chaining.
Recursion is probably one of the oldest concepts in programming. It's the paradigm where a function calls itself.
The main building block of every application is the function. You've probably heard that the functions in JavaScript are first-class citizens.
The previous chapter showed us that the main instrument in JavaScript is the function. And if something is getting run, again and again, it makes sense to try optimizing it.
Developers that used to write in functional languages feel good with JavaScript because the language supports functional concepts. One of them is partial application.
Another popular functional programming paradigm is currying. It is kind of similar to the partial application in the sense that it allows us to split the function call.
Dependency injection (DI) or inverse of control (IoC) is a concept that is not popular in the JavaScript ecosystem.
State machines must be taught equally as every other design pattern in programming. Interestingly, I started seeing state machines everywhere once I found this concept.
Now when we know what a state machine is, we can talk about `reducers`. That term became popular around the Redux library, where it is the main actor.
Flux architecture is one of those popular things that the ecosystem replaces with something new. Back in the early days of React, this pattern was the answer to many questions.
In this book, the Flux architecture chapter is before Redux on purpose. Historically Redux came after Flux and, it has almost the same structure. The one-way direction data flow is still here.
CSP (communicating sequential processes) is a formal language for describing patterns of interaction in concurrent systems. It's used in ...
In this section of the book, we will learn about six of my favorite design patterns. The first one is called "singleton".
Like a singleton, the factory pattern falls into the category of creational patterns. Those are patterns that are focused on the initialization of the objects.
The revealing module pattern is the one that I use the most in my daily job. Back in the days when we didn't have classes, this pattern was my primary tool for mimicking OOP.
Often, we use design patterns in programming without even knowing that they exist. The publish/subscribe pattern is one of them.
A mixin is a set of helpers that we can inherit. In the world of JavaScript, this is often an object that we merge with another one.
The idea of the command pattern is to separate the objects that trigger logic from the objects that implement it. The trivial variant involves ...