To publish a project bootstrapped with Create React App to your site on GitHub Pages, you have two options: publishing from a gh-pages branch or from master/docs.

For either method, you need to link the local repository created by Create React App to a remote on GitHub. I use GitHub Desktop (File -> Add local repository [unchecking Keep this code private] -> Publish repository), but of course you can also use the command line.

From master/docs

  1. Create a folder at your project root level (at the same level as the src and public folders) named docs. Add any file in it, like…

Here’s a brief summary of the differences between forEach(), for-in, and for-of loops to keep handy as reference.


The forEach() prototype* method, introduced in ES5, executes a provided callback function (a function passed to another function as an argument) once for each value in Array, Map (made up of key-value pairs), Set, NodeList (an array-like object often returned by Document.querySelectorAll()), or HTMLCollection (an array-like object often returned by Document.getElementsByClassName()) objects, in ascending order.

myArray.forEach(function (value) {
// Do stuff

It takes a function callback as a parameter, with the current value being processed in the array as its argument…

There are two methods of defining a function in JavaScript: the function expression and function declaration. They’re similar, but there are a few important differences you should be aware of.

First, here are some things they have in common:

No Return Statement?
Functions don’t require an explicit return statement. Without one, a function returns undefined by default. Additionally, when a function does include a return statement, the specified return value is not returned until the function is called.

Parameters Are Optional
In both function declarations and function expressions, parameters (what’s inside the parentheses — this variable or expression is called a…

Immediately Invoked Function Expressions (IIFEs) Explained

An imediately invoked function expression (IIFE), pronounced ‘iffy’, is a JavaScript design pattern often used to minimize naming conflict and create private variables.

The conventional format for an IIFE is to enclose the whole function within the grouping operator (a set of parentheses) and to leave it unnamed (i.e., anonymous). The additional set of parentheses at the end is what immediately invokes it:

(function() {
// Function contents

Before we get into IIFEs at a more detailed level, let’s review the differences between function declarations and function expressions.

Function Declaration vs Function Expression

A “function declaration” (synonymous with…

Introduced in the JavaScript specification update ECMAScript6 (2015), the keywords let and const have largely overtaken var for variable declaration. For instance, section 5.1.1 of the Google JavaScript Style Guide instructs that you:

Declare all local variables with either const or let. Use const by default, unless a variable needs to be reassigned. The var keyword must not be used.

In this article, you’ll learn about things like scope, hoisting, and which variable you should use, in the context of ES6 variable declaration syntax.

Some basic terminology to start us off…

  • A variable stores information to be referenced and manipulated in a computer program.
  • Scope refers to…

The terms “statement” and “expression” are thrown around quite a bit in the JavaScript world. But what do they mean?


A statement is a line of code that performs some action.

For example, if, while, and for are statements; they perform actions or control actions but don’t resolve to values.

x = 5; is a statement because its effect is assignment (it is changing x).

Although semicolons are automatically inserted where needed thanks to automatic semicolon insertion (ASI), it’s still considered good practice to insert a semicolon at the end of a statement (except for function, if, switch, try, and…

Natalie Cardot

aspiring web developer |

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