JS core concepts

Devi - Mar 12 - - Dev Community

Closures example:

The closure is a javascript nested function where we can access outerfunction variables inside the inner function by calling the innerfunction inside the outer function.

let outerfunction = ()=>{
var count = 0
let innerFunction=()=>{
count++;
console.log(count)
}
return innerFunction;
}

let increment = outerfunction()
increment();
increment();
increment();
increment();

. . . . . . . .
Terabox Video Player