/javascript

Learning JavaScript

Primary LanguageJavaScript

JavaScript

Variable Declaration in JavaScript

var

var statement is used to declare variables in JavaScript that are function-scoped.

let

let keyword is also used for variable declaration. But the only difference is the variable declared with the “let” keyword is block-scoped and local variable.

const

The const declaration creates an immutable reference to a value. It does not mean the value it holds is immutable — just that the variable identifier cannot be reassigned.