JavaScript Glossary: Essential JS Terms Explained

This glossary explains the most important JavaScript terms you will see in documentation, tutorials, error messages, and code reviews. It is designed to help you read JS code more confidently and understand the language’s core vocabulary in practical, beginner-friendly language.

Quick answer: A JavaScript glossary is a reference list of common JS words and concepts, such as scope, closure, hoisting, callback, and promise. Use it when you need fast, accurate definitions and want to avoid confusing similar terms.

Difficulty: Beginner

You'll understand this better if you know: basic JavaScript syntax, variables, functions, and how to read simple code examples.

1. What Is a JavaScript Glossary?

A JavaScript glossary is a reference collection of terms used to describe the language, its syntax, and its runtime behavior. Instead of teaching one feature in depth, it gives you clear definitions so you can quickly look up a concept and understand how it fits into JavaScript.

This kind of reference is especially useful because JavaScript has many words that sound similar but behave differently, such as undefined and null, or function and method.

2. Why JavaScript Glossary Terms Matter

JavaScript documentation often assumes you already know common vocabulary. If you do not, even a short explanation can feel difficult to follow. Learning these terms makes it easier to read error messages, understand API docs, and communicate with other developers.

Many bugs are really misunderstandings of terminology. For example, if you know what scope means, you are less likely to expect a variable to exist outside the place where it was declared. If you know what a promise is, you can better understand why async code does not run in the same order as synchronous code.

3. Basic Syntax or Core Idea

This article is not about one syntax rule. Instead, it explains the core ideas behind important terms you will see throughout JavaScript.

Example of how glossary terms appear in code discussions

The following snippet shows a few common terms in context: a variable, a function, a callback, and a promise.

const message = "Hello";

function greet(name) {
  return `Hello, ${name}`;
}

const result = Promise.resolve(42);

setTimeout(() => {
  console.log(greet(message));
}, 1000);

These words do not all mean the same thing. The glossary helps you separate the language features from the code that uses them.

4. Step-by-Step Examples

Common term: variable

A variable is a named container for a value. You use it when you want to store data and use it later.

let count = 1;

This line declares a variable named count and stores the number 1 in it.

Common term: function

A function is reusable code you can call by name. Functions often accept inputs and return outputs.

function square(n) {
  return n * n;
}

This function takes one input and returns its square.

Common term: callback

A callback is a function passed into another function so it can be called later.

setTimeout(() => {
  console.log("Done");
}, 500);

Here, the arrow function is the callback. setTimeout stores it and runs it after the delay.

Common term: promise

A promise represents a value that may be available now, later, or never. It is central to asynchronous JavaScript.

const dataPromise = Promise.resolve("ready");

This promise is already resolved, but in real code promises often come from network requests or timers.

5. Practical Use Cases

6. Common Mistakes

Mistake 1: Confusing undefined and null

These values both mean “no useful value,” but they are not identical. undefined usually means a variable exists but has not been assigned, while null means you intentionally set a value to empty.

Problem: Treating them as the same can lead to weak checks and confusing logic, especially when testing for missing data.

let userName;

if (userName == null) {
  console.log("No name");
}

Fix: Be explicit about what state you are checking for and use strict comparisons when possible.

let userName = null;

if (userName === null) {
  console.log("No name was assigned intentionally");
}

The corrected version makes the intent clear and avoids loose equality surprises.

Mistake 2: Using callback to mean any function

Not every function is a callback. A callback is specifically a function passed into another function to be called later.

Problem: Calling every function a callback can make documentation harder to understand and hide the real control flow.

function add(a, b) {
  return a + b;
}

const sum = add(2, 3);

Fix: Reserve the word callback for functions passed as arguments to be invoked by another function.

function runLater(callback) {
  setTimeout(callback, 100);
}

runLater(() => {
  console.log("Now this is a callback");
});

The fixed example shows the function being passed for later execution, which is what makes it a callback.

Mistake 3: Thinking hoisting means everything moves to the top

Hoisting is often described too casually. In practice, declarations are handled differently depending on whether you use var, let, const, or a function declaration.

Problem: Assuming all declarations behave the same can cause ReferenceError messages when code reads a variable before initialization.

console.log(value);
let value = 10;

Fix: Declare variables before using them, especially with block-scoped declarations.

let value = 10;
console.log(value);

This works because the variable is initialized before the read occurs.

7. Best Practices

Use precise terms in code reviews

When discussing code, saying “this value is undefined” is more helpful than saying “it is empty.” Precision reduces misunderstanding and speeds up debugging.

if (typeof input === "undefined") {
  console.log("Input was not provided");
}

Using exact terms helps other developers map the discussion to the actual language behavior.

Separate syntax from runtime behavior

Some glossary terms describe source code structure, while others describe what happens when the code runs. Keeping them separate makes concepts easier to learn.

const items = [1, 2, 3];
const first = items[0];

The array syntax is visible in the code, but the behavior of reading from the array happens at runtime.

Use glossary terms consistently

If you call something a method, make sure it is actually a function attached to an object. If you call something a property, it should be a value, not a callable operation.

const person = {
  name: "Ava",
  sayHi() {
    return "Hi";
  }
};

This distinction matters because it changes how you access the member and how you describe the object’s API.

8. Limitations and Edge Cases

9. Practical Mini Project

This small reference object demonstrates how a glossary page might store a term, a definition, and an example. It is a simple pattern you can reuse for note-taking or learning tools.

const glossaryEntry = {
  term: "closure",
  definition: "A function that remembers variables from its outer scope.",
  example() {
    function makeCounter() {
      let count = 0;

      return function () {
        count += 1;
        return count;
      };
    }

    const counter = makeCounter();
    return counter();
  }
};

console.log(glossaryEntry.term);
console.log(glossaryEntry.definition);
console.log(glossaryEntry.example());

This example shows how a term and its meaning can be stored alongside a working code sample that demonstrates the idea.

10. Key Points

11. Practice Exercise

Use the glossary idea to test your understanding of common JS terms.

Expected output: A short glossary note with five terms, each followed by a simple example and a one-sentence explanation.

Hint: Keep the definitions short and practical. Focus on what the term means in real code, not on memorizing a textbook phrase.

Solution:

const glossary = [
  {
    term: "variable",
    definition: "A named place to store a value.",
    example: "let age = 25;"
  },
  {
    term: "function",
    definition: "Reusable code you can call by name.",
    example: "function greet() { return 'Hi'; }"
  },
  {
    term: "callback",
    definition: "A function passed into another function to run later.",
    example: "setTimeout(() => console.log('Done'), 1000);"
  },
  {
    term: "promise",
    definition: "An object representing a future result.",
    example: "Promise.resolve('ready').then(console.log);"
  },
  {
    term: "closure",
    definition: "A function that remembers outer variables.",
    example: "function outer() { let x = 1; return () => x; }"
  }
];

glossary.forEach((entry) => {
  console.log(entry.term, "-", entry.definition);
  console.log(entry.example);
});

This solution gives you a reusable glossary structure and reinforces the terms with examples you can actually run.

12. Final Summary

A JavaScript glossary is one of the fastest ways to build confidence with the language. It helps you translate unfamiliar words into clear ideas, especially when reading documentation or debugging code.

The most useful glossary terms are the ones that describe how JavaScript really behaves: scope, closure, hoisting, callback, promise, undefined, and null. Once these feel familiar, many other topics become easier to learn.

If you want a good next step, read a deeper guide on JavaScript functions, scope, and asynchronous programming so you can connect these terms to real code patterns.