An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
September 29, 2022 04:16 am GMT
Original Link: https://dev.to/khalidhossain/fundamentals-of-let-const-var-48fl
Fundamentals of let, const, var
Variables: Variables in JavaScript are containers for storing data. JavaScript allows the usage of variables in the following three ways:
var:
var is the most commonly used variable in JavaScript. It can be initialized to a value, redeclared and its value can be reassigned, but only inside the context of a function. It can be function scoped or globally scoped.
let:
let in JavaScript is similar to var only difference lies in the scope. var is function scoped, let is block scoped. It cannot be redeclared but can be reassigned a value.
const:
const in JavaScript is used to declare a fixed value that cannot be changed over time once declared. They can neither be redeclared nor be reassigned. They cannot be hoisted either.
Connect with me on LinkedIn
Original Link: https://dev.to/khalidhossain/fundamentals-of-let-const-var-48fl
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To