What exactly Just in time (JIT) compilation is in JavaScript?
I'm a college dropout turned self-taught developer. I transform documented ideas into functioning scalable tech products.
Search for a command to run...
I'm a college dropout turned self-taught developer. I transform documented ideas into functioning scalable tech products.
No comments yet. Be the first to comment.
Have you ever been in a situation where your code runs in one browser and fails in another? And you would be wondering what the hell is happening?? Even after checking your code thoroughly, over and over again, you find it 100% correct. Then where t...
It took me 4-days and 100+ attempts to solve this simple issue of uploading a file using node. And the moment I got it right, I was like...phewww Here is how I solved this issue. By creating a - Simple node server. Middleware to process files. PO...
Whattttt??? Yes, You read that correctly. Let's deep dive into this topic. Before we get into a serious drill, Let's quickly revise objects and functions in JavaScript. Object: Objects in JavaScript are nothing but a non-primitive type data structu...
Again a jargonish word, but let me demystify it for you. It's nothing but a simple technique we use to prevent unnecessary function calls to improve app's performance. Unlike Debouncing, here we block a function call for a particular time if it's be...
Is JavaScript compiled language or interpreted language or a mix of both?
Don't worry! Take a chill pill 😎
I'll break it down for you, bit by bit.
But first thing first...
Take a deep breath, and follow along.
JavaScript engines use the JIT(just in time) compiler to execute the code.
I know you must be wondering what the hell is JIT and how it works?

Let me demystify it for you
But before understanding JIT, let's change the topic for a while, and try to understand what compiler and interpreter are and how they work?
Compiler
The source code is converted into machine code once and then gets executed.

Pros
Cons
Interpreter
Interpreters are quick. We don’t have to go through that whole compilation step before execution. It just starts translating the first line and then executes it.

Pros
Cons
Just In Time(JIT) compiler
To get rid of the interpreter's inefficiency, "the interpreter keeps retranslating the same code every time it goes through the loop".
In the JIT compiler, we have a new component called a monitor (aka a profiler). That monitor watches the code as it runs and

In short Just in time compiler is nothing but a combination of an interpreter and a compiler.
I hope you found it helpful, and if you have any questions, please let me know.
Feel proud to correct me if I'm wrong:)