How JavaScript executes: Expressions
To understand what kind of JavaScript code is currently executing, let’s start with what we know about the JavaScript language.
We know that JS is an embedded, interpreted language, without input and output. The place where JS is embedded is called the HOST. For example, a browser is a HOST. The JavaScript language is embedded inside the browser.
An Agent is embedded inside some HOST that can execute JavaScript code. Typical Agents, or the most common runtime, are V8 Spider Monkey, JS Core.
We start with expressions
Why do we get such a result by entering such lines in the browser in the console?
The bottom line is that in a unit of time, the command that enters the interpreter is disassembled into its components, and without fail, all these components are calculated (executed).
Get Andrei Smolka’s stories in your inbox
Join Medium for free to get updates from this writer.
That is, each part of this code is calculated.
When we write command 2026. Then a command goes inside our interpreter (let’s call it that for now). 2026 it is not a number that adds up to something. 2026 is an expression.
JavaScript command that arrives inside our agent, and it forces our agent to execute this command.
In the case of command 2026, according to the ECMA specification, executing command 2026 should return the number 2026.
Summary
In interpreted languages, what see on the screen may not be exactly what we think it is.
References:
ECMAScript spec — https://tc39.es/ecma262/









