This way of line-by-line execution also means that errors are only thrown when the interpreter reaches the source code line that has an error in it. Since there is no initial pass through even syntax errors are only thrown at runtime while executing that specific line.
"These are languages typically processed by compilers, though theoretically any language can be compiled or interpreted." (source).
This states again, that any language can be compiled or interpreted depending on the context of where the language is used.
Compiled languages generally go through two phases before the program can be executed.
The result of the compilation is a machine readable, portable (binary) representation of your program.
Again, in a visual (from the YDKJSY series):
Compiling your program before executing it means that we can catch errors early on. Not all errors though; static errors like syntax errors. It's really helpful that these errors are thrown before the code is executed on your users machine or on a server triggered by a user.
Let's get to how a JavaScript program is run:
NOTE: A JIT compilation is compilation during execution of a program (at run time) rather than before execution.
As you can see, the process doesn't match either an interpreted or a compiled language process exactly. It contains traces from both an interpreted language and a compiled language. Code is executed top to bottom in runtime and errors are thrown once the program gets to them in the execution phase. However, before execution the source code is parsed and compiled in runtime, but also transpiled and bundled during build time.
Nowadays most JavaScript source code is transpiled and/or bundled at build time. These transpilers and bundlers go through all our program's source code and show us static errors that are in there.
Unfortunately, this catches not all errors. There is always a chance that there is more errors during runtime. You could prevent part of these by setting up a test suite or re-actively act on them by setting up an error logging service.
So, what type of language is JavaScript? With the above information you could draw your own conclusion. You could also go on the internet and read about what others think of it. This page on MDN for example gives a great summary of the JavaScript language next to sources to get to learn more about it. Or this Wikipedia page that lists all type of languages and explains what they mean.
However, what matters most is that you understand on a high level how your code is executed once it leaves your editor. Understanding it helps you to become a better developer. It gives you the ability to predict what code is prone to errors and what type of errors, where and how code can be optimized and it helps you understand why some things do or do not work in different environments.
If you liked this article and want to read more make sure to check the my other articles. Feel free to contact me on Twitter with tips, feedback or questions!