---
title: 'What Is JavaScript'
source: 'https://academia.sh/en/courses/javascript-fundamentals/what-is-javascript'
course: 'JavaScript Fundamentals'
language: en
updated: '2026-08-23T07:00:58+00:00'
license: 'CC BY-SA 4.0'
---

# What Is JavaScript

The distinction between language, engine, runtime, and standard; the boundary between what ECMAScript defines and what the host environment adds.

The Programming Fundamentals course established the concepts of variable, expression,
condition, loop, and function independent of any language. This course does not look at
what those same concepts correspond to in a single language; it looks at that language's
own particular decisions: which scope a name is seen in, which rule decides whether two
values are equal, which steps convert one type into another.

Before starting this examination, a distinction is needed. The name "JavaScript" covers
three separate things at once in everyday speech: a language, a program that runs that
language, and the services around that program. This lesson's subject is the boundary
between these three. Without knowing the boundary, the question of why a script running
in a browser does not run on a server also has no answer.

## Language, Engine, and Runtime

The **language** is syntax and semantics: which sequences of characters make up a valid
program, and what a valid program means. Constructs like `const`, `+`, and `if`, and
their behavior, belong to the language.

The **engine** is the program that runs the language. It parses the source text,
converts it into an internal representation, and executes it. The hybrid model from the
How Computers Work course's Compiler, Interpreter, and Virtual Machine lesson applies
here: the source is first converted into bytecode, and frequently run sections are then
converted into machine code through just-in-time compilation. This is why "JavaScript is
an interpreted language" is incomplete; the execution model is the engine's decision,
not part of the language's definition.

The **runtime** is the host environment around the engine. The engine alone cannot read
a file, write to a screen, or connect to a network. The host environment supplies these
abilities. A browser is a host environment; it offers document objects and page events.
A server-side runtime is also a host environment; it offers a file system and network
sockets.

The three layers can change independently of one another. The same language can be run
by different engines; the same engine can be embedded inside different host
environments.

## What the Standard Says, and What It Does Not

The language's definition is the standard called **ECMAScript**. The relationship
between this name and "JavaScript" is historical; throughout this course, **JavaScript**
will be written when the language itself is meant, and **ECMAScript** when the rule set
by the standard is meant.

The standard's scope is fixed:

- Syntax and grammar.
- Value types and the operations on them.
- Built-in objects: `Object`, `Array`, `String`, `Math`, `JSON`, `Date`, `Map`, `Set`,
  and the like.
- Abstract operations: step-by-step defined procedures such as how two values are
  compared, or how a value is converted to a number. This course's Values and Types
  topic reads largely from these procedures.

What falls outside the standard's scope matters just as much. Writing to the screen,
reading a file, sending a network request, setting a timer, and accessing a document
are not defined in ECMAScript. All of this work comes from the host environment. Even
the `console` object is not part of the standard; the reason it is commonly found is
not that it is standard, but that host environments choose to provide it.

## Testing Where a Name Comes From

The distinction should not stay abstract: which layer a name comes from can be tested
directly. The `typeof` operator produces `"undefined"` for an undefined name without
throwing an error, which makes it suitable for probing.

```js
console.log(typeof globalThis.Math);      // comes from the standard
console.log(typeof globalThis.JSON);      // comes from the standard
console.log(typeof globalThis.console);   // comes from the host environment
console.log(typeof globalThis.document);  // exists only in a document-based environment
```

When run in a server-side runtime:

```
object
object
object
undefined
```

`Math` and `JSON` are found in every ECMAScript environment. `console` exists in this
environment, but it comes not from the standard, it comes from the environment itself.
`document` does not exist: a document object is something a page-displaying environment
supplies. When the same four lines are run in a browser console, the fourth line
produces `object`; the first three do not change.

`globalThis` is the name for reaching that environment's global object in a portable
way. Because the global object's name differs across environments, portable code uses
this name.

A practical rule follows from this: if a script is meant to "run everywhere," it must
rely only on the names the standard defines. The moment file reading or writing to the
screen is needed, the script has bound itself to a host environment.

## How a Script Is Executed

When a file is run, there are two separate phases, and the difference between them is
the foundation for reading error messages.

**Parsing** happens first. The entire source text is resolved according to the grammar.
An error found at this stage is a syntax error, and not a single line of the program
runs:

```js
console.log("does this line print?");
const x = ;
```

When this file is run, `does this line print?` is **not printed**. The output only
reports the error; the core of the message is this:

```
SyntaxError: Unexpected token ';'
```

If parsing succeeds, **execution** begins. An error arising at this stage is a runtime
error, and the lines before it have already run:

```js
console.log("this line prints");
const record = null;
console.log(record.temperature);
```

```
this line prints
```

Execution then stops, and the following message is given:

```
TypeError: Cannot read properties of null (reading 'temperature')
```

In both cases, the runtime writes the file's full path, the line the error is on, and a
stack trace before the message. These lines vary by machine and version, so this course
shows only the unchanging part of an error's output. Reading an error message is
detailed in the Ways to Run Code lesson.

The threefold distinction established in the Programming Fundamentals course's What Is a
Program lesson — syntax error, runtime error, logic error — applies here exactly as it
was. The only thing that changes is that which stage the error appears at can now be
observed concretely.

## The Course's Axis: Measurement Records

Throughout this course, a single concrete problem will be worked on: a list of readings
coming from a set of measurement stations. This list will grow lesson by lesson; first
plain numbers, then records with fields, and eventually a data set that is read from
text, converted, and written back to text.

Its first form is nothing more than four temperature readings:

```js
const temperatures = [21.5, 19.75, 23, 18.25];
let total = 0;
for (const value of temperatures) {
  total += value;
}
console.log("reading count:", temperatures.length);
console.log("highest:", Math.max(...temperatures));
console.log("average:", total / temperatures.length);
```

```
reading count: 4
highest: 23
average: 20.625
```

Every name in this script belongs to one of two sources. `const`, `let`, `for`, and `of`
belong to the language; `Array` and `Math` belong to the standard's built-in objects;
`console` belongs to the host environment. Running the script in a browser changes only
the last binding — the language's and the built-in objects' behavior stay the same.

Notice the `23` in the output: `23` was written in the source, and `23` is what is
printed, not `23.0`. This detail of number display is the subject of the Values and
Types topic, and is a direct consequence of the How Computers Work course's Floating-
Point Numbers lesson.

## Summary

- The name "JavaScript" covers three layers at once: the language, the engine that runs
  it, and the host environment around the engine. The three can change independently.
- The language's definition is the ECMAScript standard; the standard covers syntax,
  value types, built-in objects, and abstract operations.
- Writing to the screen, reading files, network access, and document objects are not in
  the standard; they come from the host environment. Even `console` is in this class.
- The probe `typeof globalThis.name` tests which layer a name comes from without
  throwing an error.
- A parsing error runs no line at all; a runtime error appears after the lines before it
  have already run.

## Next Step

Where a script runs determines which names are found. The next lesson takes these
execution paths one by one: the browser console, a script tag attached to a page, and a
server-side runtime invoked from the command line. The same measurement script will be
run all three ways; where the difference between them comes from, and which part of an
error message is worth reading, will be seen.
