Closures in Javascript
Closures in Javscript
Closure is not a feaature that we explicity use so we don;t create closure manually, like we create a new array or a new function. so a closure simply happens automatically in certain situations, we just need to recognize those situations.
const secureBooking = function () {
let passengerCount = 0;
return function () {
passengerCount++;
console.log(passengerCount);
}
}
const booker = secureBooking();