Back to JavaScript Errors
JavaScript Error

ReferenceError

Variable is not defined

What does this error mean?

Occurs when trying to access a variable that has not been declared or is out of scope.

How to fix ReferenceError?

Check if the variable is declared before using it. Make sure the variable is in the correct scope.

Example
console.log(x); // ReferenceError: x is not defined