Syntax Error
ELI5 — The Vibe Check
A syntax error is when you write code that the computer cannot even understand — like handing someone a sentence with no verbs. It is caught before the program even runs. The good news: syntax errors are the easiest to fix because the editor usually shows you exactly where you messed up.
Real Talk
A syntax error occurs when source code violates the grammatical rules of the programming language and cannot be parsed. The compiler or interpreter rejects the code entirely before execution begins. Modern editors with LSP support highlight syntax errors in real time. Common causes include missing brackets, unclosed strings, wrong keywords, and invalid punctuation.
Show Me The Code
// SyntaxError examples:
// Missing closing bracket:
function greet(name {
return `Hello ${name}`;
}
// SyntaxError: Unexpected token '{'
// Unclosed string:
const msg = "Hello world;
// SyntaxError: Invalid or unexpected token
// Using a reserved word:
const class = 'myClass'; // 'class' is reserved
When You'll Hear This
"It's just a syntax error — missing a comma." / "TypeScript catches syntax errors before you even run the code."
Related Terms
Bug
A bug is anything in your code that makes it behave wrong.
Compiler
A compiler is like a translator that reads your entire code book, converts it all into a language the CPU understands, and hands you the finished translate...
Logic Error
A logic error is the sneakiest kind of bug — the code runs perfectly fine, no crashes, no errors, but it does the WRONG thing.
Runtime Error
A runtime error is one that only shows up when your program is actually running, not before.
Syntax
Syntax is the grammar rules of a programming language — where to put the curly braces, where to put semicolons, how to write a function.