I am studying this answer and I came across a doubt in a test I am performing, it 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>
Then my doubts:
a) When calling the function x()
everything in it should not be
executed?
b) How do I y()
and z()
run?
c) How to change function parameters in the call?
d) The error that occurs is that the functions have not been defined, so as to correctly define these functions and parameters ?