Blockscoped
Blockscoped, in the context of programming, refers to a scoping model where bindings are limited to the innermost block that contains them. In JavaScript, block-scoped declarations are created with let and const, introduced in ECMAScript 2015. Unlike var, which is function-scoped, let and const are confined to the block enclosed by curly braces, such as the body of an if statement, a loop, or a try/catch block. This behavior helps prevent variables from leaking into outer scopes and reduces certain categories of bugs.
Key characteristics of block-scoped bindings include the temporal dead zone and different hoisting behavior. A let
Block scope is a widely used concept beyond JavaScript, and many other languages provide block-level scoping,