6
I’m studying that answer and I came across a doubt in a test that I am performing, follows :
<script>
function x(a1="a1"){ // "x" tem acesso a "a"
var a2="a2";
console.log("Consele fx =" + a1);
console.log("Consele fx =" + a2);
function y(b1="b1"){ // "y" tem acesso a "a" e "b"
var b2="b2";
console.log("Consele fy =" + a1);
console.log("Consele fy =" + a2);
console.log("Consele fy =" + b1);
console.log("Consele fy =" + b2);
function z(c1="c1"){ // "z" tem acesso a "a", "b", e "c"
var c2="c2";
console.log("Consele fz =" + a1);
console.log("Consele fz =" + a2);
console.log("Consele fz =" + b1);
console.log("Consele fz =" + b2);
console.log("Consele fz =" + c1);
console.log("Consele fz =" + c2);
}
}
}
x(10);
//Consele fx =10
//Consele fx =a2
y();//erro
z();//erro
</script>
So my doubts :
to) When calling the function x()
everything inside shouldn’t be
executed ?
b) How do I y()
and z()
be executed ?
c) How to change function parameters in the call ?
d) The error that gives is that the functions have not been defined, then as correctly define these function and parameters ?
Now I’m starting to put the chopsticks together... VLW man well explained... I’m going to do more tests to deepen myself...
– MagicHat