There are several ways of writing JavaScript functions. In this article I’ll explain each and every one of them and illustrate in which situation we’d like to use each particular one.

Function Declaration

The first and most traditional way of writing a function in Javascript is the function declaration, a.k.a. function definition or function statement.

Indeed this is when we use the function keyword to declare the function, just loosely telling JavaScript that it exists in the middle of the code.

In this case, there is only one way to do it. And it’s by creating a named function. …

A few months back, I wanted to leverage my career as a software engineer and get to the next level.

When I mentioned that to a good friend of mine in the industry, he introduced me to Mateus Freira and said that he could mentor me.

Mateus told me we could work together on an example project for this project he was building: Nun DB.

In exchange, I would have an excellent project in my portfolio, and he would go with me through all the nuance involved, namely all the best practices and any other tips he could give me…

So what is the deal with the var, let and const keywords?

Have you ever run into that JavaScript online tutorial and seen the old var declaration? I bet.

But the JavaScript course you recently bought didn’t even mention this keyword and always used let or const, right?

Let’s explore the differences and find out when to use each one of them.

var keyword

The ancient var keyword was the first and only way of declaring a variable in JavaScript until ES6 first came out in 2015.

For many years, this was the only option available for every program, tutorial or book…

boxes representing javascript scopes
boxes representing javascript scopes

This is a follow up on my last post about JavaScript Scope. So if you haven’t checked it out yet, go ahead and take a look there first!

As a brief recap, we saw the rules for storing and searching for variables in JavaScript. We also explained how we can compare scopes to boxes inside other boxes.

Now, you’re probably wondering what actually constitutes a scope in JavaScript.

As a matter of fact, JavaScript has two kinds of scope, and which kind it’ll use depends on the kind of variable declaration we’re dealing with.

Let’s take a closer look.

Function Scope


While learning JavaScript, one may find the term scope being used all around.

If you’re not an experienced programmer, it’s likely you already have an idea of what that means, but you’re probably not sure.

This is actually a very deep subject, so we’re only gonna brush over it.

What is Scope?

Simply put, when we talk about scope in JavaScript, we mean the set of rules for storing and later finding variables.

A second meaning for scope is where we store and find a given variable.

So, basically we’re dealing with three questions:

  • what are the rules for storing a variable?
  • what…

representatin of a Node aplication login page with Firebase Authentication
representatin of a Node aplication login page with Firebase Authentication

What is Firebase Authentication?

Firebase Authentication is a service compatible with your Node.js app offered by Firebase, which is a BaaS maintained by Google.

Moreover, it’s a service that might help you save a lot of time when creating the authentication service of your Node.js app.

Why bother?

Firebase Authentication will save you much time in your future Node.js projects, thus it’s a very nice trade-off to give up a few hours learning how it works.

Namely, it practically does all the dirty work in the backgroung for you in a very straightfoward and simple manner. Your only mission is to use it properly.

Why not do all by myself?

Above all…

Image of a fireball similar to the Firebase logo
Image of a fireball similar to the Firebase logo

What is Firebase?

Firebase is a BaaS, an acronym that stands for Backend as a Service, which is nothing more than a couple of online solutions to aliviate customer efforts of configuring and mantaining the backend for their application.

Specifically, Firebase is one of the most popular examples of a BaaS, and is currently owned by Google.

As a result, it provides a whole basket of products that can help you develop your application without wasting a lot of time and resources setting up and upkeeping your backend.

Which services can Firebase provide?

Amongst the services that Firebase provide are the following:

  • A realtime database
  • Cloud functions
  • Authentication

The current Node.js authentication solutions

Many articles have been written around this topic: “Create a Login System with Node.js”, “Node.js Authentication”, etc.

Currently, the most popular option for implementing your own authentication system is Passport.js.

If you follow these tutorials or start reading library documentation I bet you’ll come to the same conclusion as I have. The fact is that authenticating users with Node.js might be very cumbersome and specially dangerous task.

The implementation challenges

You’ll need a database to store user credentials, a data model, and you’ll have to set up the whole authentication architecture. And even with the help of specialized Node.js …

Pedro Köhler

Full stack web developer specializing in JavaScript

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