This feature is also there in C and C++ and probably other languages. The catch is that js seems to have inherited the syntax but not the scoping rules.
Has that not been fixed since ES2015?
const a = 5;
console.log(a)
{
const a = 10;
console.log(a)
}
console.log(a)
5
10
5
What we are missing from say Rust in js is the blocks being expressions, though there is a proposal ("do expressions") to allow this: const a = do {
if (b) { 5 } else { 10 }
};
https://github.com/tc39/proposal-do-expressions