Errors are statements which don't let the program run properly. There are three main types of errors that can occur while compiling a JavaScript program. These errors include syntax errors, runtime errors, and logical errors.
- 1. Syntax Errors (most common)
Incorrect syntax raises parsing errors and occur at the interpretation time. Simple example is to introduce a semicolon where a double-colon it's needed.
let exObj = { name; 'Rick' }
- 2. Runtime Errors
Occur after the compiler interpret the code, when the code ran. Also known as exceptions. It can occur by calling a function that It wasn't declared.
The syntax is correct but the function is not present.
// calling not declared function
doSomeStuff()
- 3. Logical Errors (most difficult to find)
Error in the flow of data. The logical elements are well structured, the syntax is correct, but the confluence of data lands improperly.
Consider the script "There is a movie called Terminator 2". Consider the happy ending statement path: ''John Connor kills Terminator.''
Now consider a logical error: ''Terminator kills John Connor.''
These kind of errors change how your program should work from the result we would expect.
Synthesis
- syntax errors : while interpretation. Simple example: misspelling.
- runtime errors: while execution. Simple example: due to misuse.
- logical errors: scrambled logical perform. Simple example: ''Terminator kills John Connor.''
Top comments (1)
Senichi, I would add dev.to/frankfont/look-professional... as a good way to quickly debug logical errors --- even after shipping.