Question 78
Question
Answer
function outerFunction() {
let message = "Hello from outer";
function innerFunction() {
console.log(message); // InnerFunction 'borrows' and logs 'message'
}
return innerFunction; // Return the nested function
}
const myClosure = outerFunction();
myClosure(); // Output: Hello from outer (closure still has access)Last updated