JSFiddle - React, Tailwind, and code Playground
JavaScript
// Isso:
function f() {
var a = 10;
var b = 10;
c();
function c() { console.log("f.c"); }
var d = function() {};
}
// é equivalente a isso:
function f2() {
function c() { console.log("f2.c"); }
var a = undefined, b = undefined, d = undefined;
a = 10;
b = 10;
c();
d = function() {};
}
// Mas isso:
function g() {
var a = 10;
var b = 10;
var c;
c();
function c() { console.log("g.c"); }
var d = function() {};
}
// NÃO É equivalente a isso:
function g2() {
function c() { console.log("g2.c"); }
var a = undefined, b = undefined, c = undefined; d = undefined;
a = 10;
b = 10;
c();
d = function() {};
}
f();
f2();
g();
g2();