The parameters of the outer function will also be available in the inner one:
function test(num) {
function func() {
console.log(num); // shows 1
}
func(); // calls the inner function
};
test(1); // passes a number as a parameter
Determine what will be output to the console without running the code:
function test(num1, num2) {
function func() {
console.log(num1 + num2);
}
func();
}
test(1, 2);
Determine what will be output to the console without running the code:
function test(num1, num2) {
function func() {
console.log(num1 + num2);
}
num1 = 2;
func();
}
test(1, 2);