Skip to content

Declaring variables in JavaScript

Last updated on January 18, 2020

This post helps to understand and know real usage of variable declaration with new keywords introduced in ESNext version.

In ES5, using var keyword we can declare/define variable.

<var isInitialized = false;>

Since ES6, we have additionally two keywords are introduced since then those usages are increased well among developers. let and const keyword.

const COUNT = 5;
let isInitialized = false;

var keyword is function scoped whereas let and const keywords are block scoped.

As a best practice, constant variables will always have to be Upper case letters while naming, positioned at top of file.

Published inJavaScript