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.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay