JavaScript Engine and  V8 Engine.

JavaScript Engine and V8 Engine.

Context given by software environment to JavaScript Engine.

·

2 min read

This short article will cover below topics.

  • What is JS Engine?

  • What is JS V8 Engine?

  • What is JS Context?

A JavaScript engine is software that executes JavaScript code. Chrome uses v8 Engine to execute JS code.

Now,

what is V8?

According v8.dev website "V8 is Google’s open source high-performance JavaScript and Web Assembly engine, written in C++. It is used in Chrome and in Node.js."

But again In simple words "Its(V8) just name given by inventor to JS Engine".

Do you know JavaScript engine work in context ?

Now what is this context?

To understand this take an analogy,

You know any IDE(Visual Studio, IntelliJ IDEA, PyCharm.) for C++ , or java, when you run java program it can access your file system , you can play with OS processes.

Here, IDE gives context of file system, operating system to that java or CPP program.

Similarly,

think about Our web browser, it runs only web pages, For JavaScript Engine It gives access to DOM(Document Object model which represent whole web page inside the web browser).

JS1.PNG

So in the case for JavaScript Engine your web browser gives context of DOM.

Hope context is clear..

But wait..

Ask few question to yourself,

1) Can we directly communicate with Operating system from browser?

Answer is : "No" (It'll considered as vulnerable So browser will prevent you to do so).

2.Can you access your file system from chrome directly?

Again answer will be NO.

So here is challenge faced by developer " What if they want to use JavaScript like any other programming language? "

In order to find answer of above question developer found one way i.e. Taking that Java script Engine outside of browser and give it access to rich context than browser provides.

Yes, Take that JS Engine outside of browser.

Now once JS Engine comes outside of browser now context is not limited to just web pages but its depends on which software Environment in which JS Engine is used.

Look at below diagram

JS2.PNG

software XYZ gives access to API of OS, file system to JS Engine , now we can use JS as like any other programming language.

Node JS is doing same(more than that..)and analogy is like similar.

Next time whenever you hear word node.js remind yourself with below diagram

JS3.PNG

Hope this article add small value in your existing knowledge.

Thank you. Have a great Day..