Johnny

@smpnjn

3682 Points 57 Followers

191 Posts

0 Answers

Engineer, Product

Johnny · 1 week ago

Javascript: Check if an Array is a Subset of Another Array

There are many use cases where knowing if an array is a subset of another can be quite useful - and although usually immediately obvious to the human eye, it can be difficult to evaluate in...

Johnny · 1 week ago

Javascript Array Every Method

Sometimes with arrays, we want to test every element for a certain condition. While individual conditions can be tested easily with an if statement, it becomes a little trickier with multipl...

Johnny · 1 week ago

Creating and Generating UUIDs with Javascript

Universally Unique Identifiers (UUIDs) are used all over the place in software development for everything from identifying object elements to DOM elements on a web page. They are unique, 128...

Johnny · 1 week ago

Javascript Array Concat Method

The concat method on arrays is used to take two arrays and concatenate them into one. It takes as many arrays as you like - so you can concatenate many arrays at once: Array.concat(value1, v...

Johnny · 2 weeks ago

Javascript Immediately invoked function expressions (IIFE)

Immediately invoked function expressions, or IIFE, are functions which are run as soon as you define the function. You may also see people refer to them as anonymous functions. They give us...
3

Johnny · 2 weeks ago

Javascript loops: for vs forEach vs for.. in vs for.. of

There are quite a few ways in Javascript to loop through an array of items or any other iterable item in Javascript. You may have seen them: arr.forEach() for(let item of arr) for(let...
1

Johnny · 2 weeks ago

Removing the last element of an array in Javascript

One of the most frequent operations we perform on an array is removing the last element. There are a few different ways to do this - but one of the most common is to use the pop() method. Co...
1

Johnny · 2 weeks ago

Javascript Ordinals: Adding st, nd, rd and th suffixes to a number

In Javascript it's usually considered best practice to work with absolute numbers, as number is a defined type. However, when expressing these numbers in user interfaces, it's more likely we...

Johnny · 1 month ago

Git: Renaming a Branch

Git branches are an easy way to manage our code, and separate our copies of our code when we want to work on specific features. We can then merge our code back into our main branch, or even...
2

Johnny · 1 month ago

Git Merge: Merging Changes from other Branches

Git provides a powerful tool by letting us create branches. When our branch is done, we'll often want to merge it back into our main or master branch - or perhaps even merge it into another...
4

Johnny · 1 month ago

Resolving Git Merge Conflicts

Merge conflicts are often a part of life for working on complex development projects. In this guide we'll look at how you can deal with them, and when they will occur. When do merge conflict...
4

Johnny · 1 month ago

A Step by Step Guide to Git Branches

In my previous guide on getting started with git, I briefly covered how git branches work. You can create new branches using the git branch command, for example. In this guide, we'll go in d...
1

Johnny · 1 month ago

Javascript Shallow Copy - what is a Shallow Copy?

Shallow copy and deep copy are terms thrown around in Javascript that can be confusing if you have never heard them before. It is quite common to hear that array methods like slice or filter...

Johnny · 1 month ago

CSS Individual Transform Properties

CSS transforms are a useful way to translate, rotate, and create 3d objects in CSS. I covered previously how CSS transforms work here, and I also created a 3d Minecraft chicken to show how y...

Johnny · 1 month ago

Javascript Proxy: Using Javascript Proxies like a Pro

Proxies are objects in Javascript which allows you to make a proxy of an object, while also defining custom behaviour for standard object operations like get, set and has. What that means is...

Johnny · 1 month ago

The Complete Beginners Guide to Getting Started with Git

Git can be daunting to understand since it is completely driven from the terminal, but at its core it's just version management software. It lets us maintain versions of code, which other pe...

Johnny · 1 month ago

What are NodeLists, and how do they work?

Did you know that Javascript does not class a selection of multiple elements as an array? Instead, it is something called a NodeList. A node list is essentially a list of elements. To genera...

Johnny · 1 month ago

Javascript Add Event Listener to Multiple Elements

If you've ever worked in vanilla Javascript, you might be familiar with adding event listeners to elements using the following formula: let element = document.querySelector('#button'); elem...

Johnny · 1 month ago

Javascript Array Filter Method

The filter method in Javascript creates a shallow copy of an array, filtering it based on a number of conditions. It accepts a callback function. The array which filter produces will usually...
1

Johnny · 1 month ago

Javascript Array Reduce Method

The Javascript reduce method is a recursive way to perform a computation based on every element in array, while also taking into consideration the previous element in the array. It accepts a...
1

Johnny · 1 month ago

Javascript Array Slice Method

The slice method on arrays returns a shallow copy of a part of an array. It takes two numbers, a start, and an end. Every array has a slice method. Here is a quick example: let myArray = [ '...
2

Johnny · 1 month ago

The Difference between TypeScript and Javascript

If you're new to web development, or just Javascript development, you may find yourself wondering what is the difference between TypeScript and Javascript?. In this guide I'll explain exactl...
2

Johnny · 1 month ago

How to get the last element of an Array in Javascript

So you have a Javascript array, and you want to get the last element. Take this example, for instance: let myArray = [ '🔩', '⚡️', '🔑', '🖇' ] This array has 4 items - and as you might kno...
1

Johnny · 1 month ago

Updating Object Key Values with Javascript

Javascript objects consist of key value pairs and are one of the most common data structures in Javascript. To update all values in an object, the easiest way is to: Use Object.keys to get...
1

Johnny · 1 month ago

Waiting for the DOM to be ready in Javascript

When you're working with Javascript, you're likely to have run into a pretty common problem: if your Javascript appears before your HTML, then trying to do things like attach events to your...
1

Johnny · 1 month ago

The Essential Guide to Javascript Sets

In a previous article, I covered Javascript Maps - a data type very similar to objects, but with some key differences. Javascript has other data types too, and one you may not know much abou...
2

Johnny · 1 month ago

Transporting your Components Anywhere with React Portals

When we create components in React, normally they exist within the component tree. This is mostly fine, but sometimes we want certain parts of a component to appear outside the component tre...
4

Johnny · 1 month ago

Setting the Default Node.JS version with nvm

When developing projects and products in Node.JS, it becomes essential to set the Node.JS version being used on your computer. nvm is a really useful tool for changing your Node.JS version o...
3

Johnny · 1 month ago

How to count all files in a directory in Linux

To count all files in a directory in linux, simply cd to that directory and then run the following command: ls | wc -l Alternatively, you can select the directory by adding the directory to...
1

Johnny · 1 month ago

Python: The Difference Between Sets, Lists, Dictionaries and Tuples

Python has four types of data collections. When to use which, and why we have four, can be confusing. In this guide I'll go through what each of the types are, and how to use them. The four...
2

Loading More Content