'Is JavaScript interpreted or JIT compiled?

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?



Solution 1:[1]

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.

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anands23
Solution 2 sielakos