JavaScript Variables
Learn about the different types of variables in JavaScript.
By the end of this lesson, we’ll be able to understand the differences between var
, let
, and const
and how to use them correctly.
In JavaScript, variables can be declared with var
, let
, or const
.
Note: The
let
andconst
keywords were introduced in ES6 and are the preferred variable declaration methods for this course.
Variable update
The var
variables can be updated and redeclared within its scope.
Let’s take a look at the code below. What will be logged to the console? Why?
Get hands-on with 1400+ tech skills courses.