What is the closure function in Javascrpt(javascrpt)

JavaScript Closures Quiz

JavaScript Closures Quiz

1. What will be the output of the following code?

function outerFunction() {
    let outerVar = "I am from the outer function";

    function innerFunction() {
        console.log(outerVar);
    }

    return innerFunction;
}

const closureExample = outerFunction();
closureExample();
        



2. What is a closure in JavaScript?




3. Which of the following is an advantage of using closures in JavaScript?




Comments

Popular posts from this blog

React Interview Questions - Controlled vs Uncontrolled

gg