Variables are names identifiers for values. We declare variables in javascript using var and let keywords. See both declarations below.
//var declaration
var name;
//let declaration
let age;
Differences between both declarations,
var | let | const |
declares a function scope variable if defined inside of a function, otherwise a global/module scope. | declares a block scope variable. | declares a block scope variable |
optionally initializes to a value | optionally initializes to a value | Need to initialize while declaration. |
declarations are hoisted to the top of the function scope. | Not hoisted | Not hoisted |