JSFiddle - React, Tailwind, and code Playground
by cwtuan
JavaScript
var i;
for (i = 0; i < 10; ++i) {
var x = 1;
}
// function will create a new scope
function foo() {
var y = 1;
x++;
}
console.log('x', x); // 1
foo();
console.log('x', x); // 2
console.log('y', y); // Uncaught ReferenceError: y is not defined