Overste
Overste

Reputation: 119

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?

Upvotes: 11

Views: 7924

Answers (3)

pradeep kumar
pradeep kumar

Reputation: 1

Javscript is nowdays a mix of interpreter and compiled lannguage , it's called JIT compilation and let me tell you what's this and how our JS engine executes code.

so when you write the code , js engine tokenizes the code and converts it to AST ( a tree like structure ) then it goes to Profiler ,Profiler's main work is that check for the code that runs repetitively like a loop or a function which is called many times and it takes that part of the code and throw it to TurboFan Compiler , turbofan's main job is that it optimize and compiled that portion of code into optimized binary and then run. and other parts of code runs interpreted by Ignition compiler which converts the code into ByteCode and runs.

Upvotes: -2

Anands23
Anands23

Reputation: 780

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.

Upvotes: 8

sielakos
sielakos

Reputation: 2404

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.

Upvotes: 3

Related Questions