Class and Function Hoisting in JS

An important difference between function declarations and class declarations is that while functions can be called in code that appears before they are defined, classes must be defined before they can be constructed.

class hoisting

Classes defined using a class declaration are hoisted, which means that JavaScript has a reference to the class. However the class is not initialized by default, so any code that uses it before the line in which it is initialized is executed will throw a ReferenceError.

    const p = new Rectangle(); // ReferenceError
    class Rectangle {}

This occurs because while the class is hoisted its values are not initialized.

Function and class expression hoisting

Function expressions and class expressions are not hoisted.



let and const Keywords Hoisting

Variables defined with let and const are hoisted to the top of the block, but not initialized. Meaning: The block of code is aware of the variable, but it cannot be used until it has been declared.

Using a let variable before it is declared will result in a ReferenceError.

The variable is in a “temporal dead zone” from the start of the block until it is declared:

\\ This will result in a ReferenceError:

carName = "Volvo";
let carName;

Using a const variable before it is declared, is a syntax errror, so the code will simply not run.

carName = "Volvo";
const carName;



Stateless and Stateful

The state of an application (or anything else, really) is its condition or quality of being at a given moment in time—its state of being. Whether something is stateful or stateless depends on how long the state of interaction with it is being recorded and how that information needs to be stored.


A stateless process or applicaton can be understood in isolation. There is no stored information or references to past transactions. Each transaction is made as if from scratch for the first time. Think of stateless transactions as a vending machine: a single request and a response.


Stateful applications and processes, however, are those that can be returned to again and again, like online banking or email. They’re performed with the context of previous transactions and the current transaction may be affected by what happened during previous transactions. For these reasons, stateful apps use the same servers each time they process a request from a user.


Redhat blog

Learn in Public

Learning in public is fastest way to build your expertise, network, and second brain. It will also attract luck.


  • Write blogs , tutorials and cheat sheets.
  • Speak at meetups and conferences.
  • Ask and answer things on Stack Overflow or Reddit. Avoid the walled gardens like Slack and Discord, they’re not public.
  • Make YouTube videos or Twitch streams.
  • Start a newsletter.
  • Draw cartoons.

Oh you think you’re done? Don’t stop there:

  • Enjoyed a coding video? Reach out to the speaker/instructor and thank them, and ask questions.
  • Make PR’s to libraries you use.
  • Make your own libraries no one will ever use.
  • Clone stuff you like, from scratch, to see how they work.
  • Teach workshops.
  • Go to conferences and summarize what you learned.

People think you suck? Good. You agree. Ask them to explain, in detail, why you suck.

At some point you’ll get some support behind you. People notice genuine learners. They’ll want to help you. Don’t tell them, but they just became your mentors.

Eventually you run out of mentors, and just solve things on your own. You’re still putting out content though. You see how this works?

Learn in public.


Josh Branchaud
Aaron Francis