Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Welcome back.
So we know that this thing called the JavaScript engine takes our written JavaScript code and does some
magic to tell the computer to do what we want it to do.
So what's happening inside of this engine?
And here's the tricky part.
As we know, this engine can be built by anybody.
Yes, that means you can build your own JavaScript engine, but it's a lot of work.
And at the end of the day, it's just a program.
And the V8 engine, which is the most popular, most common, and some would say the fastest JavaScript
engine that the Chrome browser and Node.js uses, which we'll talk about later on.
This engine is written in C++, a low level programming language.
But let's see what's actually happening inside here.
Inside this engine, it looks something like this.
We give it a JavaScript file.
And first, as does something called lexical analysis, which breaks the code into something called
tokens to identify their meaning so that we know what the code is trying to do.
And these tokens are formed into what we call an AST.
That is an abstract syntax tree.
So we parse the code that is, we try and figure out how the text is divided up based on key words from
JavaScript, and it gets formed into this tree like structure called abstract syntax tree.
And this is a fun little tool online that you can use to demo this.
If we go to ASD Explorer dot net, I'll show you how this abstract syntax tree looks like.
And you have a bit of code here.
And as you can see, you can look at it in JSON format or you can use it the tree.
And it breaks down the program into different things that are happening.
We have a variable declaration.
A decorator.
And although this may look like gibberish right now to you, this allows the engine to understand what's
going on in the program or at least break things down one by one.
And once ends this form, it goes through something called an interpreter.
Profiler compiler and we get some sort of code which we're going to talk about later on.
And this whole engine is going to spit out some code that our CPU on our computers is going to understand
to give it instructions.
And you can think of this whole process again, which we're going to talk about in more detail coming
up as something like this.
We can create our own JavaScript engine by saying function.
And let's say Jay's engine function that takes him some code.
And this code is going to return for us.
Let's say code dot split.
And we'll use some regex here just to split up our code.
And now if I write some code here, let's say JJ's engine and we give it our code, which will be a
string that says variable A equals to five.
Look at that.
We've created a simple engine.
I know, I know there's a lot more complexities to it than that, but that's what it's doing.
We're giving it a piece of code which just gets string ified.
And then it tries and breaks things down into different parts so that maybe in this function we can
say if you see variable keyword, that means whatever comes after it is a variable that we're going
to assign and so on and so forth.
But you might see a problem here.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.