JavaScript Tutorial

Disadvantages of Closures

Potential memory leaks and increased memory usage.

// Memory leak example
const leak = [];
function createFunc() {
  const largeObject = new Array(1000000);
  leak.push(() => console.log(largeObject));
}
createFunc();