How to Read a JavaScript Error Without Panicking
The page went blank and the console is full of long English text. Here is how to read it line by line — most errors are solved just by reading them properly.
The first reaction to an error is usually to delete the line and retype it, or to search the whole error message. Both waste time. The message already contains the answer — you just need to read it in the right order.
Read the message from the bottom up
Uncaught TypeError: Cannot read properties of undefined (reading 'name')
at showUser (app.js:42:18)
- The last line (at ...): where exactly — file, line, column.
- The first line: the type and description.
Always start with the last line. Location matters more than description, because descriptions are sometimes misleading.
The five most common messages and what they mean
- Cannot read properties of undefined → you are reading a property of something missing. The element is not in the page, or the function returned
undefined. - is not a function → the name exists but is not callable. Usually a typo, or the thing has not loaded yet.
- X is not defined → the name does not exist at all. Either you forgot to define it, or it is out of scope.
- Unexpected token → a syntax error: missing bracket, extra comma, unclosed quote.
- Failed to fetch → the request failed: wrong path, CORS, or no network. Not a code bug.
Tools that save hours
- console.log — not a crime. Print values before the suspicious line instead of guessing.
- debugger; — one line pauses execution in the browser and lets you step through with live values.
- Network tab — for request errors. If fetch failed, the real cause is here (status and response).
The rule that makes the difference
If the error makes no sense — read the line before it. Most errors are caused by a line that executed one step earlier, not by the error line itself.
Train one habit: every time you fix an error, write one line about the real cause. In a month you will recognise most of them at a glance — and that, not the number of languages you know, is the difference between a beginner and a professional.