"ReferenceError" in JavaScript — What It Means and How to Fix It
What the JavaScript error "ReferenceError" means and how to fix it.
Published October 29, 2026
"ReferenceError" is thrown when code references a variable that doesn't exist in any accessible scope.
Key points
- Check the browser console's stack trace to find exactly which line and call triggered the error
Example
console.log(x) // ReferenceError: x is not defined