Is JavaScript translated from source code to machine code with a JIT compiler or an interpreter? Or does it depend on the browser and the JavaScript engine you are running?
Asked
Active
Viewed 6,674 times
11
-
2https://en.wikipedia.org/wiki/JavaScript First sentence, with more information in the third paragraph. – str Jul 16 '16 at 11:50
-
1Yes, sometimes. Yes. Yes. – Bergi Oct 14 '16 at 13:16
-
You can go throw the answer: : https://softwareengineering.stackexchange.com/questions/138521/is-javascript-interpreted-by-design – NITISH KUMAR Apr 04 '21 at 07:09
2 Answers
8
Javascript is an interpreted language.It is directly interpreted by browsers for execution.
But,modern browsers support JIT compilation which converts it to bytecodes for high performance.

Anands23
- 758
- 9
- 19
3
JavaScript is scripting language and browser is executing scripts which are in text format. So by definition that makes JavaScript interpreted language.
Compiled languages are those which are executed from binary files.
JIT compilation is just something that JavaScript engines can do as way of optimization, but you never truly generate binary JS files, so language is interpreted one.

sielakos
- 2,406
- 11
- 13
-
4While the meaning of "interpeted language" is subjective, I tend to go with Wikipedia: *"An interpreted language is a programming language for which most of its implementations execute instructions directly, without previously compiling a program into machine-language instructions"*. Since the most popular JavaScript engines compile to native machine code, I would disagree with your answer. IMHO "interpreted language" is nonsensical though since you can write an interpreter for any language. – le_m Jul 16 '16 at 19:08
-
There is some point to it, I just tend to make it more practical, if it is scripting language then it is interpreted. And it is not as simple in case of javascript, because there are a lot of enignes and even those which use jit do not use it always. https://docs.google.com/document/d/11T2CRex9hXxoJwbYqVQ32yIPMh0uouUZLdyrtmMoL44/edit?pli=1#heading=h.6jz9dj3bnr8t – sielakos Jul 16 '16 at 19:26