Photo by Scott Rodgerson on Unsplash

If you are familiar with JavaScript, or perhaps any other programming language, you may have run into an issue like this:

console.log(0.1 * 0.2) 
// Returns 0.020000000000000004
// Should return 0.02

Despite 0.1 * 0.2 being equal to 0.02, we somehow get this long number with a random digit at the end. What's going on? Is JavaScript broken? Is our understanding of Math wrong? Well actually, this is known as the floating-point precision error.

How binary handles numbers differently

In base 10, which is the normal base we use in day-to-day life, we can represent a number such as 0.1 as a finite number —…


Photo by cottonbro from Pexels

Recently, I have been buying a house. Houses are funny — you can put money down on a property without the guarantee that you’ll actually be able to live in it. You can get expensive surveys done, or you can get a solicitor to work with you before the seller has even agreed to sell the property. This concept is strange to me. Why would I pay money for something that I have no guarantee of living in?

I would essentially be spending money to learn useless facts about a random property until it becomes mine. …


Photo by Skylar Kang from Pexels

A lot of the work we do with JavaScript involves us sending information back and forth from servers. You are probably familiar with the concept of APIs, which send data to servers or websites in a particular format, to get a specific response back.

These are known as REST APIs. Although useful, they are not very good at constant streams of data. If you try to do something real-time with REST APIs, you’re going to have a bad time. Fortunately, if we want a real-time connection with a user, we have an alternative, known as WebSockets.

How WebSockets work

Websockets are essentially constant…


Photo by fauxels from Pexels

Building web applications is something a whole generation of developers have grown up with. Building phone applications in android and iOS, however, usually requires knowledge of Swift or Kotlin, which may not be your first language in programming.

Having all your code work on all devices, in the same repo, is the dream scenario for those building web first. Fortunately we can accomplish just that with Apache Cordova. In this article, we’ll be looking at how you can take your React project and transform it into a native iOS or Android application. Let’s get started.

Note: This tutorial is based…


Photo by Ferenc Almasi on Unsplash

Web components will be familiar to you if you have worked at all with React. They are custom, replicable pieces of HTML, which can be referred to elsewhere in the code.

Web components are their own HTML specification, so you may be surprised they can be used in a standalone manner with pure JavaScript and HTML. Let’s take a look at how to do that.

Imagine we have a status bar item which we reuse in multiple places. The structure of it might look like this:

Imagine having to paste that into multiple places and maintain it so it…


GraphQL is a language built primarily for use with APIs. It interacts with JavaScript and other languages quite easily. In this article, let’s take a look at the basics around how to combine Express, MongoDB, and GraphQL into a basic API for getting titles and dates from a database.

GraphQL is a bit of a departure from classic REST APIs, but once you get used to it you’ll see how easy it can be to run. Let’s take a look.

Install GraphQL

The first step is to install the standard GraphQL packages and Express on your Node.js …


It’s often useful to get a list of the most popular pages on your website or app, either to feed into analytics, or to build UI elements which show users what your most popular content is. In times gone by, a hit counter might be used to track your most popular pages.

However, in the modern world, it’s much easier to use the Google Analytics API. Since Google has recently updated Analytics to ‘Google Analytics 4’, and also changed the Javascript API, I thought I’d write a guide on how I’ve done this on my website, Fjolt. …


CSS does a lot with its selectors, but there’s still a lot more it could do to make things easier for developers. In this guide we’ll be looking at some of the main developments coming from the CSS Selectors Specification 4, and how it might make your development life easier.

These are, for the most part, not currently supported by browsers!. For a more comprehensive view of current selectors, read A complete guide to get you started with CSS Selectors.

:has

Parent Selection. We all want it, and :has tries to solve it. Not supported by any browsers currently mostly due…


I recently started a new blog with NodeJS where I was quickly faced with the conundrum of how to notify users when a new article is published. Most importantly, I wanted to do all of this without depending on a third party service. I thought this would be a great opportunity to use web notifications.

Native browser notifications only really work when a user has the website open. I wanted all users to get a notification from the server when something new happened, whether the website was open or not.

But if the user has the page closed, how can…


WebP is a web format that seems to pop up every now and then when browsing the net. In the past, I have written it off as a niche file format that won’t give me any real benefits. I wrote it off, that is, until I started using it. WebP is perhaps one of the most innovative file formats for the web, but its uptake has remained low relative to its value. So why should you be using WebP?

.WebP has massive size benefits

⛏ WebP is way smaller

WebP is significantly smaller than what you’re currently using, and that’s a certainty. WebP is on average 22% smaller than a…

Johnny Simpson

@fjoltdev on twitter

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