Learn how to write asynchronous programs using promises and async/await

There is no doubt that JavaScript, despite its history, has become to be one of the most popular programming languages today. JavaScript, due to its asynchronous nature, can present some challenges for those who are new to the language. In this article, we are going to write small async programs using promises and async/await. Using these examples, we are going to identify some simple patterns that you can use for your own programs.

If you are new to JavaScript, you may want to first check out my other article before reading this one.

All the code examples in this article…

In this article I’ll walk you through modeling Social Library, a social app for book enthusiasts, using GunDB. This fictitious app helps readers create favorite lists from the books they like, leave reviews and follow other readers and authors. I’ll start by talking about what data modeling is and then I’ll walk you through creating a graph data model for the app. Then, I’ll implement the entities and relationships with GunDB, and finally I’ll create some fake data and show you how to run some queries against the data. If you just want to read the GunDB-related portion, you can…

Exploring the basics

Recently I’ve been playing around with GunDB and I wanted to share with you what I’ve learned so far. GunDB, a.k.a Gun, a.k.a Gun.js, is more than just a graph database. It’s a group of projects that aims to simplify scaling, improve data security, save costs, and empower application developers.

In this article however, I’ll explore Gun exclusively as a database. By focusing only on the database aspect I can keep the article less overwhelming and explore other aspects in the upcoming articles as I make progress and learn more.

All the code examples for this article are available on…

How do JavaScript bundlers stack up against each other?

In this article I’m going to introduce you to JavaScript module loaders and bundlers. I’ll explain what they are and why they exist. First, I’ll give you an overview of the different module formats and module loaders out there and I’ll present some examples for each. Then, I’ll talk about the most well-known bundlers and I’ll compare them with each other.

If you are familiar with the different module definitions and loaders you may want to skip to the “Bundlers” section. If you just want to read the comparisons you can skip to the “Comparisons” section.

Please note that the…

In this article I’ll show you how to buy a .app domain, set up a VPS (Virtual Private Server) on DigitalOcean, and serve a simple static website using the Nginx server. Below is an overview of what I’ll be covering:

  • Benefits of .app domains
  • Buying a .app domain
  • Setting up a VPS on DigitalOcean
  • Configuring the DNS Records
  • Setting up Nginx and SSL certificates (to support https)


  • This article assumes that you have a basic understanding of the web and know the basics of the bash shell
  • All the local commands in this article are run on a Mac terminal…

After reading this article, you will know everything you need to know about coercion and the double equals operator in JavaScript.

TL;DR: always use the triple equals operator and internalize the coercion algorithms

Double Equals

The double equals operator coerces the operands if their types are not the same, otherwise, it will use the triple equals operator. So, 2 == 3 is the same as 2 === 3 because both 2 and 3 are of the number type. But if the types are not the same, JavaScript will try to coerce either one or both of the operands. For example, if you…

Learn asynchronous programming in JavaScript

The asynchronous nature of JavaScript is one of the aspects of the language that can confuse a lot of people. Having a good understanding of its primary async constructs however, can reduce a lot of confusion about the language. The goal of this guide is to introduce you to async programming in JavaScript and provide you with the necessary techniques to write clean and maintainable async code. We will start by exploring synchronous and asynchronous execution models and their differences. Then, we’ll dive into callback functions and examine how they are used to capture results of async operations. After that…

Below are some interview questions with answers to accompany the other two articles that I wrote on JavaScript functions and prototypes. The questions are grouped in three categories:

  • functions
  • closures
  • prototypes

The answer for each question is given right after the question.



What is the output of the following? And do you agree with what JavaScript outputs?

const fn = () => {};
console.log(typeof fn);


The code above outputs function. Even though the output is helpful it's not accurate. It would be more accurate to report object because functions are objects in JavaScript.


What will be the…

There are different ways to interpret the prototype concept in JavaScript, but it can be explained very easily in one sentence:

“In JavaScript, prototypes are objects that facilitate linking of objects and delegation of methods or properties”

That’s really it. The most confusing part about the prototype concept is just the terminology, but the concept itself is pretty straightforward. The diagram below demonstrates the idea in more detail:

Functions are callable objects in JavaScript. It is very important to note that in JavaScript functions are objects. It might be misleading because when you use the typeof operator on a function, you get function as the output. This is one of the instances where JavaScript lies to you. The output of typeof function () {} should be object because functions are objects in JavaScript. That makes functions very powerful, because you can think of them as callable objects. You can use a function as an object, a piece of reusable code, or a function that creates objects.

Creating Functions

There are…

AJ Meyghani

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store