let Statement (JavaScript)

Use the let statement to declare a variable, the scope of which is restricted to the block in which it is declared. You can assign values to the variables when you declare them or later in your script.

A variable declared using let cannot be used before its declaration or an error will result.

If you do not initialize your variable in the let statement, it is automatically assigned the JavaScript value undefined.