JSFiddle - React, Tailwind, and code Playground
by Nibin George
JavaScript
/**
var creates a variable scoped within its nearest parent function, let scopes the variable to the nearest block. let declares a variable with a block
*/
var i = 'default scope';
for(let i = 0; i<10; i++) {
console.info(i);
}
if (true) {
let i = 'block scope';
console.info(i);
}
console.info('Called after ', i);
/**
In ES6 a const represents a constant reference to a value. In other words, the pointer that the variable name is using cannot change in memory, but the thing the variable points to might change.const can not be reassigned
*/
const a = {
val: 234
};
a.val = 235;
console.info(a);
//a = {val: 'Differnet object here'} //error