Blog posts

Introduction to asynchronous operations in Javascript

Synchronous / Asynchronous

If you are learning JavaScript, you no doubt came across things like callbacks, promises, generators, and async / await. Those are asynchronous programming paradigms. In Javascript they are everywhere. If you want to understand JavaScript, you need to understand them. However, there is a problem.

Although there is no shortage of tutorials explaining callbacks, promises and async / await, most of them leave you scratching your head because they don’t answer one question:

What the heck asynchronous mean?

Most of the tutorials and articles I read just assume you already know that. What if you don’t? That’s why you are here.

Keep reading, and I will explain:

  • What synchronous and asynchronous mean
  • Why we need asynchronous operations
  • How asynchronous operations work
  • What kind of operations can be asynchronous in JavaScript
  • How you can make your own asynchronous operations
Read more →

Blog posts

Why are most React tutorials outdated?

Never stop learning

If you are learning React using a book or an online tutorial, you may be in for an unpleasant surprise. One minute you are following along, and then you get pissed off once you realise that the instructions you are following are hopelessly outdated. Even 5-star tutorials are best-selling books won’t protect you from that.

Read more →

Blog posts

Do I still need to bind React functions in 2019?

To bind or not to bind - that is the question

One of Reddit members asked me a question in follow-up to my answer to a question about this keyword:

Why do I need to bind a function if it’s in a class?

Short answer

You don’t need to use bind. If you use the following syntax to declare class methods, then this in them will be automatically bound to the current class instance. It’s magic.

It's magic
class MyComponent extends React.Component {
  myMethod1 = () => {
    ...
  }
  myMethod2 = () => {
    ...
  }
}

Note the absence of const keyword.

That syntax was introduced in ES6 class field declarations proposal and already widely supported. That is what you should do when you write React class-based components in 2019. bind is obsolete.

Read more →

Blog posts

When should I use “this” keyword?

To this or not to this?

When you browse through Javascript code, you often see function calls prepended with this. keyword, like this.functionName(). However, sometimes this is missing and it’s just functionName(). What is the difference and when you should use one over the other?

That depends on whether you React component is functional or class-based.

Read more →

Blog posts

Why do I need props?

Props???

If you are new to React, you may be wondering what that props business is all about. Components make sense. But why do they need props? Why should you use them, or then, or how? After all, you can build a perfectly functioning React application without those pesky props.

Well, you don’t have you use props inside your React components. It is fair that not all the components require props. But still, they are worth understanding. And here is why.

Read more →

Subscribe and receive an email when I publish a new article

* indicates required