There are lots of debates I could see about this question. Is javascript interpreted? if yes, how does the variable hoisting and closure works?
I believe Javascript is compiled language which is using JIT compiler at runtime.
There are two things to note:
That said, JS is shipped as source instead of binaries, and any up-front-compiled version would need to include an interpreter to be able to run all JS code as there isn't enough static information. So I would say interpreted is the usual implementation of JS.
Closures can work in interpreted languages just fine, perhaps more easily. Actually, almost nothing is easier for a compiler than for an interpreter, except getting good performance, because there's always more information at runtime than at compile-time.
Depends on the JSVM. V8 and Chakra use a JIT compiler. Others, like SpiderMonkey, have a mix of interpreters and JIT compilers, and I am very sure that there are pure interpreters, too.
It does not matter if JS is compiled or interpreted. Both variants tokenize the code into an AST (abstract syntax tree) before execution, so they can understand scopes, variable declarations, etc. before further processing.
Richard Ayotte
Full Stack Developer
The "both" option is missing.