All language subtitles for 4. The Node.js REPL

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian Download
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,570 --> 00:00:05,700 So what happens when I run the node program inside of the terminal? 2 00:00:07,220 --> 00:00:10,730 I'm now running note and everything I type. 3 00:00:11,060 --> 00:00:20,690 So Hello is treated as JavaScript code in this case, as a variable that hasn't been defined yet, which 4 00:00:20,690 --> 00:00:28,340 causes Node to give us this reference error when we run node and don't type anything after it. 5 00:00:28,550 --> 00:00:30,590 Not passing in any arguments. 6 00:00:31,760 --> 00:00:35,930 We're running node in a mode that's called the Rappel. 7 00:00:36,590 --> 00:00:43,400 That's our EPL, which stands for read a Val Print and Loop. 8 00:00:44,380 --> 00:00:51,160 Before we dig into that, let's think about what would happen if we typed in some code here, so say 9 00:00:51,160 --> 00:00:53,050 we added Woohoo! 10 00:00:53,770 --> 00:00:55,030 Plus who? 11 00:00:55,360 --> 00:00:59,560 Well, in JavaScript, this would concatenate the string Woohoo! 12 00:00:59,590 --> 00:01:00,870 With the string who? 13 00:01:00,880 --> 00:01:02,380 And we get woo-hoo. 14 00:01:03,370 --> 00:01:13,330 And if we take this same code and assign it to a variable, say, a constant called cheer, that variable 15 00:01:13,780 --> 00:01:17,470 is now assigned the value of this computation. 16 00:01:18,310 --> 00:01:20,170 So now if we type cheer. 17 00:01:21,210 --> 00:01:23,340 Cheer has been assigned to who. 18 00:01:24,790 --> 00:01:32,290 So what exactly is going on here when we run node and we're in our rappel, we can type in JavaScript 19 00:01:32,290 --> 00:01:39,370 code like our cheer and the rep all responds to this input in some way. 20 00:01:39,760 --> 00:01:43,060 It responds to it by reading the input. 21 00:01:43,690 --> 00:01:45,600 That's the are in rappel. 22 00:01:46,810 --> 00:01:56,140 Evaluating it, printing the results of running that computation, of running that JavaScript code and 23 00:01:56,140 --> 00:01:58,030 then loops all over again. 24 00:01:58,480 --> 00:02:07,450 So first we perform all of these actions in sequence and then we loop back to the start where our rappel 25 00:02:07,450 --> 00:02:12,460 environments will be ready to read in the next line of JavaScript. 26 00:02:12,910 --> 00:02:21,790 And this will continue until we exit the program with our Control C key combination or we Typekit exit 27 00:02:21,790 --> 00:02:22,600 and press enter. 28 00:02:23,530 --> 00:02:26,560 So what exactly does the read step here do? 29 00:02:26,890 --> 00:02:33,250 It includes reading in our code that we type with the keyboard, but also parsing that code. 30 00:02:33,640 --> 00:02:43,720 Parsing means that the V8 JavaScript engine will break down our line of code and understand the role 31 00:02:43,720 --> 00:02:46,330 of all the different parts of it. 32 00:02:46,690 --> 00:02:54,100 So, for example, it will understand that we have WUE here as a string and who as another string. 33 00:02:54,400 --> 00:02:58,090 We have this plus sign where they're being concatenated. 34 00:02:58,900 --> 00:03:08,200 We have an equal sign where the result of this, whatever that is and it hasn't been evaluated yet. 35 00:03:08,530 --> 00:03:17,080 But the parser will now know that this equal sign means that the left side here is being assigned whatever 36 00:03:17,080 --> 00:03:18,040 is on the right side. 37 00:03:19,140 --> 00:03:29,850 This past code will then be run and evaluated by Veidt, which will give us the results of this line, 38 00:03:29,850 --> 00:03:34,980 so it will add these two strings and assign them to the cheers constant. 39 00:03:35,250 --> 00:03:40,080 And finally, the results will be printed to the console in our terminal. 40 00:03:40,800 --> 00:03:49,980 So when we concatenated are strings, we added them together and the result of that expression was printed 41 00:03:49,980 --> 00:03:50,610 in our people. 42 00:03:50,880 --> 00:03:59,700 Now, when we defined our constant, we got back undefined because when we assign a constant, nothing 43 00:03:59,700 --> 00:04:01,110 is returned in JavaScript. 44 00:04:01,470 --> 00:04:06,720 It's only once we print our variable that we get the value of our string. 45 00:04:06,780 --> 00:04:07,590 Woo hoo. 46 00:04:08,040 --> 00:04:08,640 All right. 47 00:04:09,060 --> 00:04:16,380 So it's worth noting that when we're typing code into our rappel, the code that we wrote earlier sticks 48 00:04:16,380 --> 00:04:21,440 around so we could now type cheer and we would always get back. 49 00:04:21,450 --> 00:04:21,970 Woo-Hoo. 50 00:04:22,350 --> 00:04:30,450 I could create another constant greeting equals hello, and I could call that. 51 00:04:32,480 --> 00:04:39,020 But if I try to read a clear cheer, say, by creating another variable. 52 00:04:40,010 --> 00:04:42,680 And setting it to Yappy. 53 00:04:43,820 --> 00:04:52,520 I get a syntax error, which is JavaScript telling me that cheer was already declared so we could continue 54 00:04:52,520 --> 00:04:57,800 building up larger programs using the building blocks that we've already created. 55 00:04:58,130 --> 00:05:03,110 But if we close our apple and then reopen it. 56 00:05:04,230 --> 00:05:07,140 We lose track of what we were doing. 57 00:05:08,770 --> 00:05:16,450 Rebels tend to be good for quick testing of little bits of code in isolation and experimenting with 58 00:05:16,450 --> 00:05:17,680 how node behaves. 59 00:05:18,220 --> 00:05:24,970 For example, if we're curious what happens when we try to add a number to a string? 60 00:05:26,360 --> 00:05:33,620 We could test that out in our Apple, but nobody would use a rappel to write a large application. 61 00:05:34,560 --> 00:05:37,080 It's just not the right tool for the job. 62 00:05:37,470 --> 00:05:44,520 It doesn't provide a way for us to save our code or separate it into different files. 63 00:05:44,970 --> 00:05:52,560 It doesn't allow us to edit the code that we wrote previously usually will be writing our code for node 64 00:05:52,560 --> 00:05:57,180 applications in JavaScript files in code editor. 65 00:05:57,810 --> 00:06:04,620 Let's keep building up our knowledge and find out all about how to set up our node development environment 66 00:06:04,980 --> 00:06:06,600 in the next couple of videos. 67 00:06:06,630 --> 00:06:07,530 I'll see you then. 6686

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.