Closures
Closures are the combination of function and lexical scope.
Ex:
const a = () => {
let grangpa = 'grandpa';
return function b() {
let father = 'father';
return function c() {
let son = 'son';
return `${grangpa} > ${father} > ${son}`;
}
};
};
const one = a(); // [Function b]
const two = one(); // [Function c]
const three = two(); // grangpa > father > sonLast updated