If you want to have some kind of private variables in JavaScript you could place the code in an anonymous closure, right? Now since let
was included, is this specific use case of a closure gone? Or is it still relevant?
Example in top level:
// global variable a
var a = 6;
// using let
{
// new variable a that only lives inside this block
let a = 5;
console.log(a); // => 5
}
console.log(a); // => 6
// using a closure
(function() {
// again a new variable a that only lives in this closure
var a = 3;
console.log(a); // => 3
})();
console.log(a); // => 6