JavaScript Variables Documentation

1. Introduction

Welcome to the documentation for JavaScript Variables. This section provides an overview of the Variables and their functionality.

2. var Declaration

var is function-scoped and is hoisted to the top of its containing function, meaning it can be used before its declaration. However, it doesn't have block-scoping, leading to potential issues in certain situations.

var x = 5;

3. let Declaration

let is block-scoped, meaning it's limited to the block, statement, or expression where it is defined. It doesn't hoist the variable declaration, providing more predictable behavior and reducing potential bugs.

let y = 'Hello';

4. const Declaration

const is also block-scoped and, like let, does not hoist the variable declaration. The key difference is that once a value is assigned to a const, it cannot be reassigned. It is used for values that should not be changed during the program's execution.

const PI = 3.14;
Back

Data Types

Arrow