Member-only story
JavaScript Fundamentals: Variables, Scope & Hoisting
JavaScript variables are containers for storing data values. Conceptually, they’re one of the most fundamental concepts to learn. You’ve likely heard of the three ways in which variables can be declared: var
, let
& const
. In this article, we’ll be taking a look at how we declare our variables & how we name them. We’ll take a look at how variables behave in our code, with hoisting and scope (local & global).
🤓 Want to stay up to date with web dev?
🚀 Want the latest news delivered right to your inbox?
🎉 Join a growing community of designers & developers!
Subscribe to my newsletter here → https://easeout.eo.page
What are Variables?
Variables are named containers for storing data values. Any piece of information that we wish to reference multiple times can be stored in a variable for later use. In JavaScript, the value contained inside of a variable can be of any data type, including a number, string, or object.
Before the release of ES6, there was only one way to declare a variable — using the var
keyword. You’ll still see var
used quite often when working with older code. We’ll be looking at the newer conventions later in the article, but for now lets look at an example using var
: