Sobre el Hoisting, el Scope y el Shadowing

function saludar(nombre) {
console.log(`Hola, ${nombre}`);
}

saludar('Daniela');
saludar('Daniela');

function saludar(nombre) {
console.log(`Hola, ${nombre}`);
}
var x = 5;

(function () {
console.log("x: ", x); // No obtenemos '5' sino 'undefined'
var x = 10;
console.log("x: ", x); // 10
})
var x = 5;

(function () {
var x; // Ha elevado la declaración al principio
console.log("x: ", x); // 'undefined' porque sún no se le ha asignado ningún valor
var x = 10;
console.log("x: ", x); // 10
})

--

--

If something does not work, ACT. Yes, you! That’s why I’m now #Developer at @vmware . Formerly @kairos_ds .Constantly absorbing knowledge. Proud #Adalaber

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aida

Aida

If something does not work, ACT. Yes, you! That’s why I’m now #Developer at @vmware . Formerly @kairos_ds .Constantly absorbing knowledge. Proud #Adalaber