Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,100 --> 00:00:01,940
Welcome back.
2
00:00:02,240 --> 00:00:08,450
So we know that this thing called the JavaScript engine takes our written JavaScript code and does some
3
00:00:08,450 --> 00:00:12,320
magic to tell the computer to do what we want it to do.
4
00:00:13,020 --> 00:00:15,630
So what's happening inside of this engine?
5
00:00:16,079 --> 00:00:17,700
And here's the tricky part.
6
00:00:18,000 --> 00:00:21,090
As we know, this engine can be built by anybody.
7
00:00:21,360 --> 00:00:26,490
Yes, that means you can build your own JavaScript engine, but it's a lot of work.
8
00:00:26,490 --> 00:00:29,820
And at the end of the day, it's just a program.
9
00:00:30,120 --> 00:00:35,970
And the V8 engine, which is the most popular, most common, and some would say the fastest JavaScript
10
00:00:35,970 --> 00:00:41,910
engine that the Chrome browser and Node.js uses, which we'll talk about later on.
11
00:00:42,270 --> 00:00:46,920
This engine is written in C++, a low level programming language.
12
00:00:47,280 --> 00:00:50,130
But let's see what's actually happening inside here.
13
00:00:50,580 --> 00:00:54,540
Inside this engine, it looks something like this.
14
00:00:55,460 --> 00:00:58,100
We give it a JavaScript file.
15
00:00:58,960 --> 00:01:06,220
And first, as does something called lexical analysis, which breaks the code into something called
16
00:01:06,220 --> 00:01:11,260
tokens to identify their meaning so that we know what the code is trying to do.
17
00:01:11,990 --> 00:01:16,880
And these tokens are formed into what we call an AST.
18
00:01:16,970 --> 00:01:19,910
That is an abstract syntax tree.
19
00:01:19,940 --> 00:01:28,730
So we parse the code that is, we try and figure out how the text is divided up based on key words from
20
00:01:28,730 --> 00:01:34,520
JavaScript, and it gets formed into this tree like structure called abstract syntax tree.
21
00:01:35,000 --> 00:01:38,750
And this is a fun little tool online that you can use to demo this.
22
00:01:39,290 --> 00:01:46,880
If we go to ASD Explorer dot net, I'll show you how this abstract syntax tree looks like.
23
00:01:48,020 --> 00:01:50,870
And you have a bit of code here.
24
00:01:50,870 --> 00:01:55,730
And as you can see, you can look at it in JSON format or you can use it the tree.
25
00:01:56,500 --> 00:02:00,370
And it breaks down the program into different things that are happening.
26
00:02:00,610 --> 00:02:03,040
We have a variable declaration.
27
00:02:05,480 --> 00:02:06,620
A decorator.
28
00:02:06,920 --> 00:02:13,850
And although this may look like gibberish right now to you, this allows the engine to understand what's
29
00:02:13,850 --> 00:02:18,290
going on in the program or at least break things down one by one.
30
00:02:21,660 --> 00:02:26,730
And once ends this form, it goes through something called an interpreter.
31
00:02:27,620 --> 00:02:33,170
Profiler compiler and we get some sort of code which we're going to talk about later on.
32
00:02:33,410 --> 00:02:42,860
And this whole engine is going to spit out some code that our CPU on our computers is going to understand
33
00:02:42,860 --> 00:02:44,510
to give it instructions.
34
00:02:45,370 --> 00:02:51,220
And you can think of this whole process again, which we're going to talk about in more detail coming
35
00:02:51,220 --> 00:02:53,230
up as something like this.
36
00:02:53,620 --> 00:02:57,340
We can create our own JavaScript engine by saying function.
37
00:02:58,470 --> 00:03:03,450
And let's say Jay's engine function that takes him some code.
38
00:03:03,510 --> 00:03:06,450
And this code is going to return for us.
39
00:03:06,480 --> 00:03:09,270
Let's say code dot split.
40
00:03:10,450 --> 00:03:13,840
And we'll use some regex here just to split up our code.
41
00:03:16,930 --> 00:03:23,650
And now if I write some code here, let's say JJ's engine and we give it our code, which will be a
42
00:03:23,650 --> 00:03:28,060
string that says variable A equals to five.
43
00:03:30,170 --> 00:03:30,740
Look at that.
44
00:03:30,740 --> 00:03:32,840
We've created a simple engine.
45
00:03:32,840 --> 00:03:37,820
I know, I know there's a lot more complexities to it than that, but that's what it's doing.
46
00:03:37,820 --> 00:03:42,860
We're giving it a piece of code which just gets string ified.
47
00:03:43,490 --> 00:03:50,720
And then it tries and breaks things down into different parts so that maybe in this function we can
48
00:03:50,720 --> 00:03:57,410
say if you see variable keyword, that means whatever comes after it is a variable that we're going
49
00:03:57,410 --> 00:03:59,900
to assign and so on and so forth.
50
00:04:01,090 --> 00:04:04,210
But you might see a problem here.
4991
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.