Featured

JavaScript

[1] + [2] – [3] === 9!? Looking into assembly code of coercion.

Variable values have certain types. In fact, you can cast a value of one type to the other. If you do it explicitly, it is type casting (also called explicit coercion). If it happens in the background when you are trying to perform an operation on types that do not match, it is called coercion (sometimes referred to […]

JavaScript

Is eval evil? Just In Time (JIT) compiling

There is a high chance that you’ve stumbled across the JavaScript eval function.  It is a common knowledge that in JavaScript, eval is something that is a bad practice. Have you ever wondered how it works and why exactly a lot of people discourage it? This article covers that and presents some real-life usage of the eval […]

JavaScript

Handling errors in JavaScript with try…catch and finally

Mistakes happen. That’s a given. According to Murphy’s law, whatever can go wrong, will go wrong. Your job, as a programmer, is to be prepared for that fact. You have a set of tools that are prepared to do precisely that. In this article, we go through them and explain how they work. An error […]

JavaScript

Cross-Origin Resource Sharing. Avoiding Access-Control-Allow-Origin CORS error

In this article, we explain what Cross-Origin Resource Sharing (CORS) is and how to avoid errors associated with it and the Access-Control-Allow-Origin header. This includes describing it both from the viewpoint of the frontend and the backend. CORS: Cross-Origin Resource Sharing Cross-Origin Resource Sharing (CORS) is a mechanism allowing (or disallowing) the resources to be […]

JavaScript

Comparing working with JSON using the XHR and the Fetch API

Nowadays, JavaScript is often used to make Ajax requests. There are a lot of libraries that can do that for us, for example, axios or jQuery. Both of them use XMLHttpRequest (XHR). It differs from the relatively new Fetch API that was introduced a few years ago. This article explains both of them and points out their […]

JavaScript

Concatenating strings with template literals. Tagged templates

In this article, we cover ways to join strings. Even though it includes old methods of concatenating strings, we focus on template literals. Here you can learn how they work and how to expand their functionality with tags. Let’s go! Before template literals Back in the days, we didn’t have template literals and to merge […]

JavaScript

Explaining the JavaScript array. Sparse and dense arrays.

The array is a popular concept across many programming languages. At first glance, arrays work in the same way, but the JavaScript array differs from languages like C++. The article explains the basics of how JavaScript arrays work under the hood. It includes what are indexes and what is a maximum size of an array. Aside […]

JavaScript

Fundamentals of storing data in the browser with IndexedDB

IndexedDB is another API meant for client-side storage. It is good for storing a significant amount of data, including files. IndexedDB is more suitable than WebStorage suitable for keeping structured data, and definitely more adequate for that than cookies. In this article, we go through the main concepts of IndexedDB. Basic concepts of IndexedDB IndexedDB is […]

JavaScript

Object property descriptors. Getters and setters

With the properties of objects, you can set more than just their values. In this article, you can learn what is the property descriptor and what you can achieve with it. Among other things, you can use getters and setters and the article also explains their concepts. Property descriptor A descriptor is a structure that holds information […]

Uncategorized

Introduction to WebSockets. Creating a Node.js server and using WebSocket API in the browser

WebSocket is a protocol that makes two-way communication in real-time between the user and the server possible. A common use cases are chats and online multiplayer games. Today we cover implementing it both on frontend and backend. Let’s go! Explaining WebSockets WebSocket is a different protocol than HTTP. Despite that, to establish a connection, the client sends […]

JavaScript Testing

JavaScript testing tutorial – part four. Mocking API calls and simulating React components interactions

This entry is part 4 of 4 in the JavaScript testing tutorial

Today we test our React components further. It involves simulating component interactions and mocking the API calls. You will learn how to do both, so let’s go! Mocking A common thing is for our application to fetch some data from the API. A problem with it is that might fail for various reasons, such as […]