Johnny

@smpnjn

2521 Points 49 Followers

132 Posts

0 Answers

Joined February 6th, 2022

Engineer, Product

Johnny · 15 hours ago

Learn Python: Python Variables

As with all other languages, Python has variables which can be defined to hold data. As we learn about python variables, it is important to remember a few fundamental things about Python: I...

Johnny · 1 day ago

How to fix 'zsh: command not found: python'

When trying to run python from terminal, it is possible to run into the following issue: zsh: command not found: python This can happen on any system, but does occur slightly more commonly...

Johnny · 1 day ago

How to sort an array by date in Javascript

We've all been in a situation in Javascript where we have a set of data, all with different dates, which we want to sort by date quickly. Let's look at how this works. Note on Javascript Dat...

Johnny · 1 day ago

Converting Binary to Decimal with parseInt's Base Feature

Binary numbers are numbers which are expressed in base 2 notation, rather than the base 10 we are used to. Consider how we normally count in base 10 - when we reach 10, we have to add an ext...

Johnny · 1 week ago

An Introduction to Conditional Types in TypeScript

Conditional types in TypeScript give us the ability to define certain types based on logic, just like we do in other aspects of our code. They are a useful tool in defining types in TypeScri...
1

Johnny · 1 week ago

Everything you'll ever need to know about HTML Input Types

Pretty much every application we develop using HTML uses input somewhere, but there's a bunch of input types you might not know about. So let's take a look at everything you might not know a...
1

Johnny · 1 week ago

How to fix 'Uncaught SyntaxError: Cannot use import statement outside a module'

In this quick guide we'll look at how you can solve the very common error, "Uncaught SyntaxError: Cannot use import statement outside a module". This error arises when we try to us...
2

Johnny · 1 week ago

How to install nvm, the Node Version Manager

nvm stands for Node Version Management. If you don't have it installed already, in this quick guide we'll show you how to. nvm is used to manage the versions of Node.js installed on your com...

Johnny · 1 week ago

A Complete Guide to How the CSS not Selector Works

In CSS, it's often necessary to sign post that we want to select an element, but not in specific circumstances - like if it has a certain class. In these instances, we can use the :not() sel...
1

Johnny · 1 week ago

Scheduling and Running Recurring Cron Jobs in Node.JS

It's a common requirement in programming to have to set something up to run at certain intervals. For example, you might want to process a database every 30 minutes, or you might want to sen...
5

Johnny · 2 weeks ago

Speed up your Website by Converting your Images to WebP from Terminal

The .webp format is a broadly supported compressed image format that is becoming more and more common across the web. Storing your images as .webp can reduce the size of your web pages, whil...
4

Johnny · 2 weeks ago

How to use Teleport in Vue to Move Parts of Templates

Normally, when we create components in Vue they naturally appear within the DOM structure where we'd expect them to be. However, sometimes this doesn't make sense. A good example of this is...
3

Johnny · 2 weeks ago

How to set default inject/provide values in Vue

Vue uses provide and inject as a method to send data down multiple levels without having to use properties - but did you know you can set default values for any injected data, should it not...
4

Johnny · 2 weeks ago

How Provide and Inject work in Vue

It's easy in Vue to provide/give props or properties to a child element. Properties in Vue are one of the main ways we can pass data from a parent element or vue template to a child element....
3

Johnny · 4 weeks ago

How does Optional Chaining work in Javascript?

Optional chaining is a feature in Javascript which lets us access child properties of an object, even if the parent object doesn't exist. It's used when properties are optional on an object,...
3

Johnny · 4 weeks ago

How does the Javascript logical AND (&&) operator work?

The logical AND (&&) operator in Javascript is frequently used in Javascript logic, but it can also be used to return a value. In another article, I have covered how the logical OR (...
4

Johnny · 4 weeks ago

How the CSS Box Model Works

The CSS box model is a term thrown around in CSS with very little context, but is probably the most fundamental things you can know in CSS. Simply put, the box model determines, the size, ma...
3

Johnny · 4 weeks ago

How to Remove Empty and Non Empty Directories in Linux

Removing a directory in Linux is harder than you think, and it's not uncommon to get errors that looks like this: folder: Directory not empty folder: is a directory The confusion comes beca...
1

Johnny · 1 month ago

Truthy and Falsy Values in Javascript

In Javascript, things can be true, or false, but they can also be truthy or falsy. The concept of truthy and falsy are usually considered only in a boolean context, such as in an if..else st...
1

Johnny · 1 month ago

How does the Javascript logical OR (||) operator work?

The logical OR (or ||) operator in Javascript is an operator which returns the left hand side if the left hand side is truthy, but otherwise defaults and returns the right hand side. This me...
6

Johnny · 1 month ago

TypeScript Array Type

Arrays work the same in TypeScript as they do in Javascript, the only difference being that we have to define their type upfront. Arrays, by their nature, are an ordered list of data. Defini...
3

Johnny · 1 month ago

What is Nullish Coalescing (or ??) in Javascript

In Javascript, the nullish coalescing operator, or ?? operator is used to return the right hand side whenever the left hand side is null or undefined. To understand a little bit better, let'...
3

Johnny · 1 month ago

Type Casting in TypeScript

Sometimes, in TypeScript, something will have an unknown type where TypeScript can't discern the specific type something should be. At it's most basic, this can occur when a variable is simp...
2

Johnny · 1 month ago

TypeScript Optional Parameters

In Javascript, if a function has 4 parameters, and we only use 3, it's no big deal - Javascript just ignores the missing parameter and runs the function as if it is undefined. In TypeScript,...
3

Johnny · 1 month ago

How to make a div the same height as the browser window

You might think that making a div element the same height as your browser would be as easy as this: div { height: 100%; } However, it is unfortunately not. If you're wondering why heigh...
1

Johnny · 1 month ago

How to remove a specific item from an array

One of the most frequent tasks we have to perform in Javascript is to remove a particular item from an array. However, it's not straight forward. There is no removeArrayItem method in Javasc...
1

Johnny · 1 month ago

How to vertically center text and HTML elements with CSS

Vertically centering something in CSS is not as easy as you'd think, and until we got tools like flexbox, it was really hard. Fortunately, vertically centering something within a container i...
1

Johnny · 1 month ago

Set a div or block to its content's width in CSS

In HTML we use block elements to take up the full with of a page. These differ in properties from inline elements, which are typically found within text flow. Learn about the Box Model Both...
1

Johnny · 1 month ago

How the typeof Operator works in TypeScript

In Javascript, we already have a vanilla typeof operator which can be used to find the type of anything: let x = "hello world"; console.log(typeof x); // Returns "string"...
1

Johnny · 1 month ago

How Typescript Enums Work

Enums, short for Enumerations, are preset constants which can be defined by a developer for use elsewhere in the code. For Javascript developers, the concept of enums is usually new, but the...
3

Loading More Content