Skip to content

Day 1: "this", Closures & Hoisting

Master the internal execution mechanisms of JavaScript: closures, hoisting, and the this keyword.

A closure is a function that retains access to its lexical scope even when executed outside that scope:

function createCounter() {
let count = 0;
return function() {
count++;
return count;
};
}
const counter = createCounter();
console.log(counter()); // 1
console.log(counter()); // 2
  1. Create a function generator producing custom multiplier functions using closures (double = createMultiplier(2)).