Block
↔ Source Code Encapsulate in { }
curly braces (excl Object Literals) to define boundary of Lexical Environment
aka Blocks, Code-Block, Code-Blocks, Block-of-code
!recall if
& loop
statements are inside a block
{ const isPrivate = true }
true. can not read from outside; const block-scoped
{ var notPrivate = true }
true. readable outside Block since var
is Function Scoped
References
Global Scope
↔ Outside any Block. Variableaccess everywherefunction
↔ callable Block of code to perform action or return ValueBlock Scope
↔ Variable Lookup restrict to inside of Block{ var notPrivate = true }
↔ true. readable outside Block sincevar
is Function ScopedLoop
↔ Control Flow to repeat Block Executionif
↔ Control Flow JS Keyword to optionally execute Block on Boolean Context of expressionTop-Level Code
↔ Code in Global Scope, outside Block