DEV Community


Var vs Let vs Const in Javascript

SpeedySense Editorial
We are a team of Web developer professional. Our area of domain are Web Technologies, Programming, Linux, and Open-source ERP, We are in-depth research & share here valuable content & resources.
・1 min read

In this article, we explain the var vs let vs const in JavaScript. Also, we will look difference between var, let, and const Keywords in JavaScript. All these three keywords used to create variables in JavaScript. First of all, you must understand the var keyword to grasp the benefits of let and const keywords. So let’s start one by one.

Var vs Let
First, The main difference between var and let keyword, var is follow function scoped while let is follow block scoped. var can be available either in the global scope or function scope. let can be accessible only in enclosing block {} like in a for loop or if condition.

Let vs Const
const keyword is almost the same as let keyword except only one difference. You can’t reassign value to const variable. If you try to reassign value it will throw syntax Error (value has already been declared).

Here is great article you must have to read. Link to article: var vs let vs const in JavaScript

Discussion (0)