closure in javascript
// closure in javascript
-> A closure gives you access to an outer function’s scope
from an inner function
const outerFun = (a) => {
let b = 10;
// inner func can use variable/parameter of outer funcion
const innerFun = () => {
let sum = a + b;
console.log(sum);
}
return innerFun;
}
let inner = outerFun(5);
inner();