Skip to content
Vikyath Shirva

What is JavaScript? How does it work?

- Vikyath Shirva

This little article is an introduction to what JavaScript is and how it works. You've heard it everywhere — React.js, Node.js... js js and all the other js.

Potions Class

How does it even work?

Okay, let me break it down to you in the simplest way possible. By the time you finish reading this, you'll know what the hell JavaScript does on the web.

If you're reading this article right now, I'm sure you know what a web browser is — you're literally reading this on one. So here we go. As raw and as basic as possible: JavaScript is a scripting language. It's technically still a programming language, but it's often called a scripting language because its main job is to tell something else — like a browser — what to do. So basically, JavaScript tells the browser to do anything you ask it to. If you tell it to replace an image with another one, it will go ahead and tell the browser to do it. That's the gist of it.

So how does this thing work in the browser?

For any language to run, it needs a place to run in. As a human, you need a space to live and exist and function — you need the earth as an environment to operate. Similarly, JavaScript also needs a space to operate and execute code. The environment it most commonly uses is a web browser, but there are other places too, like Node.js web servers or any other application that accepts JavaScript code as input. For now, let's focus on the web browser.

When we write JavaScript code and run it in the web browser, there's a lot happening behind the scenes — too much to fully explain right now. The browser uses some kind of engine that takes whatever code you write and runs it. Think of it as a specialized piece of software designed to execute JavaScript code. Google Chrome uses an engine called V8. There are other engines too, such as Rhino and SpiderMonkey, but let's leave those aside for now.

Potions Class

Here's the first thing that happens in the engine: the code is read by a component called a Parser.

Think of it like a dictionary combined with a grammar textbook, but for a programming language. The parser reads your JavaScript code line by line, makes sense of it, and checks the syntax — meaning it verifies that the code is written the way the computer expects. If everything is correct, the parser moves on to the next step. Otherwise, it throws an error saying you didn't write it properly.

Once the parser understands your code, it moves to the next step and produces something called an Abstract Syntax Tree (AST).

What is an Abstract Syntax Tree?

It sounds more complicated than it actually is. Your computer has a processor, and that processor ultimately only understands very low-level instructions called machine code (binary).

Let's say you have a Spanish friend who doesn't speak English. A translator in between gives them an understanding of what you said. The AST does something similar — it's a structured representation of your code that makes it easier to translate into something the computer can understand.

The AST represents the grammar and structure of your code in a tree format. From there, the engine translates it through several stages — first into an intermediate representation, then into machine code that the processor can execute. This is a multi-step process, not a direct jump.

That machine code goes into the processor, does all the work, and sends the result back to the environment where it's running — your browser.

There you go.

Potions Class

That's what JavaScript does on the web browser, in a nutshell.

There's much more to it, but I'll keep you posted and help you understand in future posts.

© 2026 by Vikyath Shirva. All rights reserved.