Oddbean new post about | logout
 ** Understanding JavaScript Variable Declarations: Var, Let, and Const

In JavaScript, variables can be declared with var, let, or const. Each keyword has unique properties that affect their scope and reusability.

*   **Var**: Variables declared with var are in the global scope and can be accessed outside a block. They can also be redeclared and reassigned.
*   **Let**: Let variables have a separate memory space and block scope, making them inaccessible outside their block. While they can be reassigned, redeclaration within the same block is not allowed.
*   **Const**: Const variables are block-scoped and cannot be redeclared or reassigned once initialized.

Understanding these differences helps developers write more organized, efficient, and maintainable code.

**

Source: https://dev.to/ramya_srim/var-vs-let-vs-const-25aj