JavaScript: Understanding the Fundamentals part 1 of xx | Syntax Parsers, Execution Contexts, and Lexical Environments

Stojan Peshov
3 min readJul 3, 2018

--

Syntax Parsers, Execution Contexts, and Lexical Environments are concepts and ideas that are fundamental in JavaScript and with time you will build upon them.

They sound complicated but actually aren’t that difficult to understand.

Let’s break this big word:

Syntax Parsers

That’s a program that reads your code and determines what it does and if it’s grammar is valid.
Your code isn’t magic. Someone else wrote a program that can translate it for the computer.

When you write JavaScript it’s isn’t magically directly telling the computer what to do. We are abstracted away from this translation part, we are just writing code and then `something` else some program that was written from other people convert JavaScript into something that computer can understand.

Those programs are called compilers, interpreters. They read your code character by character and determining if the syntax is valid and then implementing that syntax in a way that computer can understand.

Lexical Environments

Where something sits physically in the code you write.
`Lexical` means ‘having to do with words or grammar’. A lexical environment exist in programming languages in which where you write something is important.

Lexical environment exist in programming languages in which where you write something is important — meaning that where you see things written gives you an idea of where it will actually sit in the computer’s memory and how it will interact with other variables and functions and element of the program.

That syntax parses from before cares about where you put things.
So, when you will hear about lexical environment of something in the code it actually means about where it’s written and what surrounds it : )

Execution Contexts

A wrapper to help manage the code that is running.

Image result for javascript code Execution Contexts

There are lots of lexical environments areas of the code that you are looking at physically. But which one is currently actually running? Is managed by execution context. And an execution context contains your code and It can contain things beyond what you’ve written in your code

What do you mean things beyond my code!?
Because remember our code is being translated by whole other set of programs that someone else wrote. And so, it’s executing our code and it can do other things as well and that’s what’s happening inside JavaScript.

Just remember, It’s important for you to understand these terms if you want to understand fundamentals of JavaScript. They will give us a basis to understand what’s happening under the hood in JavaScript.

--

--

Stojan Peshov

Just sharing my perspective of some Web Dev. Technologies. Get in touch by sendig an email to stojan.peshov@speshov.com or visit speshov.com directly.