let, var or const code example

Example 1: let vs const

`const` is a signal that the identifier won't be reassigned.

`let` is a signal that the variable may be reassigned, such as a counter in a
loop, or a value swap in an algorithm.

It also signals that the variable will be used only in the block it's defined
in, which is not always the entire containing function.

Example 2: const let var

var makes real ice cubes that rattle around in New York
let makes real ice cubes in Manhatten 
const is like let but the ice cubes never change because they are plastic

Example 3: const let var

var greeter;
    console.log(greeter); // greeter is undefined
    greeter = "say hello"

Tags:

Misc Example