Variables: Variables in JavaScript are containers for storing information. JavaScript permits the utilization of variables within the following 3 ways:
var:
var is essentially the most generally used variable in JavaScript. It may be initialized to a worth, redeclared and its worth could be reassigned, however solely contained in the context of a perform. It may be perform scoped or globally scoped.
let:
let in JavaScript is just like var solely distinction lies within the scope. var is perform scoped, let is block scoped. It canโt be redeclared however could be reassigned a worth.
const:
const in JavaScript is used to declare a set worth that can not be modified over time as soon as declared. They will neither be redeclared nor be reassigned. They canโt be hoisted both.
Join with me on LinkedIn