difference between var const let in javascript code example

Example 1: var vs let vs const

var: 
	- hoisted (always declared at top of scope, global if none)
    - function scope
let:
    - block scope
    - not redeclarable
const: 
    - block scope
    - not reassignable
    - not redeclarable
    
Note: Although it may seem like these hold only semantic meaning, using the
appropriate keywords helps the JS engines' compiler to decide on what to optimize.

Example 2: what is the difference between let and const in javascript

The difference is that with const you can only only assign a value to a variable
once, but with let it allows you to reassign after it has been assigned.