let & const
// var variables are function-scoped
function foo() {
if (true) { var temp = 'fooooo' } console.log(temp) // 'fooooo'}
// let, const variables are block-scoped
function foo() {
if (true) {
let temp = 'fooooo' }
console.log(temp) // Uncaught ReferenceError: temp is not defined
}const creates immutable varibles whereas variables created by let are mutable.
let withLet = 'assigned'
withLet = 're-assigned'
console.log(withLet) // 're-assigned'
const withConst = 'assigned'
withConst = 're-assigned' // TypeErrorNOTE ::: If a constant refers to an object or array, the object or array itself can still be changed