Does not support Hoisting

The behavior of moving the declarations on top of the script is known as hoisting.

Example: Let do not support hoisting.

javascript
x = 12;

console.log(x);

let x;

Output:

Uncaught ReferenceError: Cannot access 'x' before initialization 

Supported Browser:

  • Chrome 49 and above
  • Edge 14 and above
  • Firefox 44 and above
  • Opera 17 and above
  • Safari 10 and above

P.S: To clear your concept of var, and const, and let please go through How to declare variables in different ways in JavaScript?



JavaScript Let

The let keyword in JavaScript is used to make variables that are scoped to the block they’re declared in. Once you’ve used let to define a variable, you cannot declare it again within the same block. It’s important to declare let variables before using them.

The let keyword was introduced in the ES6 or ES2015 version of JavaScript. It’s usually recommended to use let when you’re working with JavaScript.

Syntax:

let variable_name = value;

Similar Reads

1. Block Scope

The variables which are declared inside the { } block are known as block-scoped variables. variables declared by the var keyword cannot be block-scoped....

2. Global Scope

A global scope variable is a variable declared in the main body of the source code, outside all functions....

3. Function Scope

A function scope variable is a variable declared inside a function and cannot be accessed outside the function....

1. Redeclaring Variables in different blocks

The variables declared using let can be redeclared inside other blocks....

2. Redeclaring Variables in the same blocks

We cannot redeclare variables using the let keyword inside the same blocks. It will throw an error....

Does not support Hoisting

The behavior of moving the declarations on top of the script is known as hoisting....