Javascript - Syntax vs Runtime Errors
Code Life
By Pierre Marsaa
Errors Are Normal
Every programmer runs into errors every single day. Seeing a red error message does not mean you failed — it means JavaScript is giving you a clue about what needs to be fixed!
To fix errors quickly, you first need to know the difference between the main kinds of errors. Here is the first kind:
↗️
Loading editor...
↶
↷
Run the code above and look closely: nothing prints to the console — not even "Battle start!" on line 1!
This is a syntax error (SyntaxError). Before running your code, JavaScript reads the entire file to check its grammar. If a statement is incomplete or a parenthesis is missing, JavaScript cannot even start running the program.
Verify