DEV Community

Ilya R
Ilya R

Posted on

1

JS LexicalEnvironment - short overview

Lexical environment is a part of context in JS. When code start running every functions, methods and block of code create their own LexicalEnvironment.

LexicalEnvironment - is a special object in JS. This object is created and called every time when code executing. If the same function is running multiple time, then every time Lexical Env will re-create inside that function.

In code we do’t have access to object of **LexicalEnv **and we can’t change that object directly. JS “engines” do it for us. They optimise Lexical Environment’s object, clean up memory by deleting variables that no longer used, etc.

The Lexical Environment object consist of:

  • Environment Record - object which store all using variables in block of code.

  • [[Environment]] - link on outer Lexical Environment. This thing using for access to Lexical Environment of “a parent’.

And in fact, JS variable is a property of an Environment Record of LexicalEnvironment. To change a variable means to change a property of LexicalEnvironment.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs