What is Lexical Scope? Lexical scope is the rule that determines where a variable can be accessed based on where the code is written . The word lexical basically means that JavaScript determines the scope by looking at the structure of the code. It does not matter where a function is called from; what matters is where that function was defined . For example: let name = " John " ; function greet () { console . log ( name ); } greet (); ...