Today’s topic is ‘JavaScript Engine’
Why we need JavaScript engine ?
Because computer is not smart enough to understand JavaScript without JavaScript engine
So, JavaScript engine work as a middle man to make computer understand the JavaScript
So what is the purpose of javascript engine ?
Make the javascript codes into machine/binary codes
Some JavaScript engines
- V8 by Google for Chrome(most used)
- SpiderMonkey by Mozila for Firexof
- JavascriptCore by Apple for Safari
- Chakra by Microsoft for Microsoft Edge
- Hemes engine by Facebook for Android apps
- See the full list in https://en.wikipedia.org/wiki/JavaScript_engine
What is V8 ?
V8 is an open-source JavaScript engine developed by The Chromium Project for Google Chrome and Chromium web browsers. The project’s creator is Lars Bak. The first version of the V8 engine was released at the same time as the first version of Chrome: September 2, 2008. (Wikipedia)
So how v8 works?
- We write codes
- It goes to v8
- finally v8 changes it to c++
- c++ changed into assembly language
- finally assembly to machine codes
Are you feeling tired after all these information ?
One tricky question for you then, if every company can make their own version of engine then they should not make it in their way right ? Why same javascript codes works on all browser in a same way ?
Tired of searching anwser ?
Because everyone follow ‘ECMAScript’. This is standardized for writing JavaScript engine!