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
French
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
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
Now while we can
easily write JavaScript code in between the script element, in a real
world application, you have 1000 maybe even a million lines of code, we don't want to
write all that code in line here. We want to extract and
separate our JavaScript code from our html code. Let me give you a
metaphor. Think of your house. In your bedroom you have your
bed, and your clothes, you don't store your clothes in the kitchen. This is
what we call separation of concerns. You have the same principle
in programming so we want to separate html which is all about content,
from JavaScript which is all about behavior. How should
your web page behave, what should happen when we hover our mouse
over a given element? Maybe something should pop up maybe something should be hidden,
so we use JavaScript to implement behavior. So,
open up the explorer window, add the new file,
call it index.js.
Now, back in index.html, cut all this
JavaScript code here, and then paste it in index.js,
now in this simple application we have a single
file, a single JavaScript file, in a real world application we have hundreds or even
thousands of JavaScript files. Later in the course you will learn how to
combine these files into a bundle, and serve that bundle into the client.
Now, save the changes, back in index.
html, now that all our JavaScript code is in a separate file
we need to reference that file here. So,
let's add an attribute here, src, which is short for src,
and set it to index.js.
So this tells the browsers that our JavaScript code
is now in index.js save the changes
back in the browser, you can still see the Hello World message
and that confirms that our code is still working. In the next lecture,
we're going to execute this code in Node.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.