JavaScript Troubleshooting Cheatsheet

Error Try this
Uncaught ReferenceError: x is not defined Declare the variable with let, const, or var before using it
Uncaught TypeError: x is not a function Make sure x is a function; check for typos or overwritten variables
Uncaught TypeError: Cannot read property 'x' of undefined Check if the object exists before accessing its properties
Uncaught SyntaxError: Unexpected token Fix syntax issues — check for extra commas, missing brackets, etc.
Uncaught RangeError: Maximum call stack size exceeded Fix infinite loops or recursion; add base cases or break conditions
Unexpected identifier / Unexpected string Double-check syntax and variable names
Uncaught Error: Something went wrong Look for custom throw statements and trace the logic
NetworkError / Failed to fetch Check the request URL, server status, and CORS settings
NaN (Not a Number) Log your values and ensure they’re valid numbers before doing math
undefined where a value is expected Make sure the variable or property has been properly initialized