1
00:00:00,940 --> 00:00:02,770
In this particular video.

2
00:00:02,830 --> 00:00:09,940
Let's see how the code that we write that is JavaScript get executed in a browser.

3
00:00:10,270 --> 00:00:17,200
Remember, JavaScript runs in the browser, so how our code gets executed.

4
00:00:17,620 --> 00:00:18,730
Let's have a look.

5
00:00:18,880 --> 00:00:25,090
Remember that all browsers has a built in JavaScript engine.

6
00:00:26,310 --> 00:00:30,450
And all these engines differ based on the browser.

7
00:00:30,990 --> 00:00:37,170
First for Chrome, we have JavaScript engine called V8 engine.

8
00:00:38,020 --> 00:00:40,060
For Firefox or Mozilla.

9
00:00:40,090 --> 00:00:46,390
The engine is called Spider Monkey and Internet Explorer.

10
00:00:46,420 --> 00:00:52,000
It also used what is called Chikara Opera or Presto, but this one is deprecated.

11
00:00:52,450 --> 00:00:59,020
So for our purposes, we are going to use the JavaScript engine that is built in into Chrome.

12
00:00:59,710 --> 00:01:03,520
So let's see how our code get executed.

13
00:01:04,360 --> 00:01:13,540
First, remember that JavaScript engine is a computer program that runs JavaScript code.

14
00:01:14,510 --> 00:01:24,290
And again, computers only understand machine code, which means that the code that we write, it always

15
00:01:24,290 --> 00:01:27,560
converts into zeros and ones.

16
00:01:27,830 --> 00:01:30,860
This is what our computers understand.

17
00:01:31,100 --> 00:01:40,760
So all the code that we write when compiling it convert into zeros and one using V8 engine.

18
00:01:40,970 --> 00:01:48,470
Now let's look at the steps involved when executing our code using V8 engine to machine code.

19
00:01:48,980 --> 00:01:51,810
So let's say that this is our source code.

20
00:01:51,830 --> 00:01:55,430
Source code represents the code that we have written.

21
00:01:55,790 --> 00:01:59,870
So before it can get executed its path through some process.

22
00:02:00,170 --> 00:02:07,520
So from source code, it will now change to what is called a AST and that is abstract syntax tree.

23
00:02:07,520 --> 00:02:09,979
And this is what you call parser.

24
00:02:10,130 --> 00:02:17,150
Meaning our code will not pass from source code to a different format called AST, which represents

25
00:02:17,180 --> 00:02:19,280
abstract syntax tree.

26
00:02:19,760 --> 00:02:27,530
Then from HD it will also convert to what is called machine code and this what you call compilation

27
00:02:28,310 --> 00:02:28,970
then.

28
00:02:28,970 --> 00:02:33,890
So machine code is a code that executed by the computer.

29
00:02:34,430 --> 00:02:41,090
Then from there, our browser now takes that, and then that process is what we call interpreter.

30
00:02:41,120 --> 00:02:44,720
Now the user sees what we have rendered.

31
00:02:44,960 --> 00:02:49,820
So this is the basic flow, how our code is get executed.

32
00:02:50,030 --> 00:02:57,380
If we want to learn more about this, you can read resources to enhance your knowledge about how code

33
00:02:57,380 --> 00:02:59,150
is being executed.

