Alejandro Oviedo García
Alejandro is a developer who loves learning new things. He is passionate about education, electronics, Open Source, and community-driven events.
var n;
declaración:
asignación:
n = 5;
function hola(){
console.log(variable);
}
¡no imprime nada!
function hola(){
console.log(variable);
}
hola();
ReferenceError: variable is not defined
function hola(variable) {
console.log(variable);
}
hola();
undefined
function hola(){
return;
console.log('mundo');
}
hola();
¡no imprime nada!
function hola() {
console.log('mundo');
return;
}
hola();
"mundo"
function hola(){
asdñkflajsdfklasdjñlfajkdsfa
console.log('mundo');
return;
}
hola();
ReferenceError: asdñkflajsdfklasdjñlfajkdsfa is not defined
function hola(){
asdñkflajsdfklasdjñlfajkdsfa
console.log('mundo');
return;
}
¡no imprime nada!
function hola(){
return 'mundo';
}
console.log(hola());
function hola() {
console.log('mundo');
return;
}
hola();
Anteriormente:
¿Qué cambia en este caso?
"mundo"
function hola(n){
for(var i = 0; i < n; i++){
console.log(i);
}
}
hola(5);
0,1,2,3,4
function hola(){
return mundo();
}
function mundo(){
console.log('prueba');
}
hola();
"prueba"
function hola(){
function mundo(){
return "mundo";
}
mundo();
}
console.log(hola());
"undefined"
function hola() {
var myVar = "mundo";
}
hola();
console.log(myVar);
ReferenceError: myVar is not defined
function hola() {
myVar = "mundo";
}
hola();
console.log(myVar);
"mundo"
function hola(miVariable) {
console.log(miVariable);
}
var miVariable = 1;
hola("mundo");
"mundo"
function hola(){
if(false) {
var mundo = 1;
}
console.log(mundo);
}
hola();
undefined
function hola(){
console.log(mundo);
var mundo = 'hoho';
}
hola();
undefined
hola()
function hola(){
console.log('mundo');
}
"mundo"
By Alejandro Oviedo García
Alejandro is a developer who loves learning new things. He is passionate about education, electronics, Open Source, and community-driven events.