JS Essentials
Published in

JS Essentials

Syntax Parser

Hello everyone and welcome to the JS Essentials. This is the platform where we are learning different JavaScript concepts. It is important to know how JS works under the hood to get a better understanding before writing any business logic.

I have started this series because I just did a course from Udemy by Anthony Alicea, ‘JavaScript: Understanding the Weird Parts’. And he explained it very well right from scratch. You may go through this cource. Most parts I am taking from this course so that everyone can read & understand conceptwise, if do not have time to go through the whole course.

Let’s begin with one of the most basic and important concepts — Syntax Parser.

The program that reads our code and determines what it does and if it’s grammar is valid.

We write code and that code isn’t a magic that computers understand as we write. Computer is not a human being, it has it’s own language. Someone else wrote a program to translate it for the computer. When we write JavaScript code, it isn’t directly asking the computer what to do. Those details are hidden from us. Someone else or there is some other program which converts our JS code into something that the computer can understand.

We can take example of human translators, take a look at above example. If person ‘A’ understands only English and person ‘C’ understands only ‘German’, then how can they communicate ? Correct, through ‘translators’ (also known as interpreters) who understands both the languages. In computer language, those programs or translators are called ‘compilers’ & they also have to do with ‘interpreters’.

But those programs — interpreters & compilers do the process. They actually read our code character by character and determines if syntax is valid and then implements that syntax in a way the computer can understand.

Suppose we have our code & there is a program that is going to convert what we have written into a real set of computer instructions, something that hardware can physically understand.

If we look at the above example, here we have a JS function with a variable which is represented in the computer’s memory and which is being translated from what we are writing to what the computer can understand. There is a compiler or an interpreter between those two things & part of that is a syntax parser.

It is going through character by character like F-U-N-C-T-I-O-N and it says oh that’s a ‘function’, so there should be a space after this. And the next thing that it looks up until the parenthesis() will be the ‘name of the function’ etc. And that’s translated by the systems that someone else wrote. But it also means in the translation process, the programmers that wrote the compiler can choose to do extra stuff. Our code is not actually being given to the computer but the translation of it, so the engine that is interpreting our code can decide or choose to do other things also.

So that’s syntax parser, interpreter between our code and computer which translates our code into machine readable code. And it’s a part of the JavaScript engine that is actually running everytime we run our JS code.

I hope you enjoy the article with the basic concept of syntax parser. In the next article we are going to talk about lexical environment and execution context. Stay tuned!




Place to learn JavaScript concepts in simple manner.

Recommended from Medium

Javascript integration with docker.

Basic Middleware Pattern in JavaScript

Friday Frontend: WebAssembly is the Future Edition

How to Build and Deploy an Angular Application Directly From GitHub

Should I Use Functional Components or Class Components In React?

Chessboard: Black and white knights facing off

How to create a custom password strength validator in Angular

What is the best way to call a REST API from JavaScript?

Best AngularJS Development Tools For Developers 2021

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anjali Tanpure

Anjali Tanpure

JS | Angular | React | PWA

More from Medium

Eleventy — Shortcode for Embedding Codepen


Final Fantasy VIII & TypeScript

Spread syntax (…)

An Introduction to ESLint