DELAPARRA
Index
Color
NL
Category: Error types

ReferenceError

Explained by Updated

What is ReferenceError?

ReferenceError: The code refers to a variable or function that does not exist (has not been declared). A ReferenceError in JavaScript means the code used a variable or function name that does not exist in the current scope. A typo, a missing import or using a variable before it is declared with let or const are common causes.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about ReferenceError

How is ReferenceError used in practice?

The message names the missing identifier, such as ReferenceError: userName is not defined, which usually makes the fix quick.

What should you keep in mind with ReferenceError?

These errors often appear only in some situations, like a code path that runs rarely or a browser without a feature you assumed. TypeScript and linters such as ESLint catch most of them while you type, before the code ever runs. A bundler that reports missing imports at build time helps too. Treat a ReferenceError in production as a sign that a check is missing from your build process.

At a glance

CategoryError types
Explained by
Updated

More Error types terms

All terms starting with R

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.