Front-end/Javascript
Lexical 🤪
madison
2022. 9. 7. 12:53
우리가 흔히 자바스크립트에서 말하는 렉시컬환경 (Lexical Environment)의 렉시컬이 무슨 뜻인지 궁금해서 찾아봤다.
lexical
[1] (adj) of or relating to words
[2] (adj) of or relating to dictionaries
단어나 사전과 연관된 뜻인걸 알 수 있다. 이어서 lexical environment에 대해 알아보면
Lexical Environment
ECMAScript 명세서 262 (8.1)에 따르면, 렉시컬 환경이란
A Lexical Environment is a specification type used to define the association of Identifiers to specific variables and functions based upon the lexical nesting structure of ECMAScript code
자바스크립트가 어떻게 동작하는지 쓰이는 이론상의 객체이다.
[1] Environment Record : 모든 지역 변수를 프로퍼티로 저장하고 있는 객체.
[2] Reference to the outer ( parent ) : Outer Lexical Environment 에 대한 참조
즉, 렉시컬 환경은 실행 컨텍스트를 구성하는 변수와 함수 정보가 있는 사전이라고 생각하면 더 와닿는다.