The variable is a fundamental concept that any developer should know.

In JavaScript, constlet, and var are the statements you can declarate variable.

I’m going to describe each variable type around the declaration, initialization, value access, and assignment. Each of the 3 types (constlet, and var) create variables that behave differently exactly in these 4 steps.

This post isn’t quite beginner friendly, but rather useful to solidify your knowledge of variables and their behavior.

Let’s get started.

1. Variable identifier

First, let’s understand what a variable is.

In simple terms, a variable is a placeholder (or a box) for a value. A value in JavaScript can be either a primitive value or an object.

The variable has a name, which stricter is called identifier. Examples of identifiers are myNumbernamelistitem.

The syntax of an identifier is pretty simple:

An identifier can contain letters, digits 0..9, and special symbols $_. An identifier cannot start with a digit 0..9.

Examples of valid identifiers are myNumbermy_numberlist1$item_nameab$_.

#javascript #variable #const #let #var

A Simple Explanation Of JavaScript Variables: Const, Let, Var
1.25 GEEK