Variables are containers for storing data values. In JavaScript you can declare variables with var, let, or const.
| var | let | const | |
|---|---|---|---|
| Scope | Function | Block | Block |
| Reassign | Yes | Yes | No |
| Hoisting | Yes | No | No |
| Redeclare | Yes | No | No |
Best Practice: Use const by default, use let only when you need to reassign. Avoid var.
Edit the code below and click Run to see the result live.