Introduction

This is a basic question, but I bet most of you will have a hard time explaining the answer to an interviewer. Let’s answer this question once and for all.

Just remember the below image.

How Javascript Works?

Now let me explain this image…

Every browser has its own Javascript engine like the V8 engine is a javascript engine for google chrome. Similarly, IE has Chakra , Firefox has SpiderMonkey. Let’s concentrate on the Google Chrome V8 engine. In this diagram, the left side represents the V8 engine with Memory Heap (memory location where an object is stored) and Call Stack (which executes the program). The whole picture represents Javascript Runtime Environment. Now let’s see with code how it works. Let’s code along, press F12 to go to console tab and paste the below code:

function hi(){  
   let dummyVariable='hi';  
   alert(dummyVariable);  
}  

hi() 

#javascript #programming

How Does JavaScript Work?
1.95 GEEK