All language subtitles for Creating a Module-en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
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
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

Original subtitles

All right.

Now let's add a new module

to this application.

So I'm going to add a new

file

logger dot

Js.

Let's imagine we're going

to create a module for

login messages and we're

going to reuse this module

in various parts of this

application or potentially

in other applications.

So, logger dot Js.

Now, in this module, let's

imagine that we're going

to use one of those remote

logging services for

logging our messages.

So there are websites out

there that provide logging

as a service, they give us

a URL and we can send an

HTTP request to that

URL to log

messages in the cloud.

So here I'm going to declare

a variable

like URL

and set it to something like

this.

Http my

logger dot io

slash log.

And of course, I'm making

this up, it may not be a

true service out there.

But let's imagine in this

implementation, we're going

to send an HTTP

request to this end point

to this URL.

Now, we also need a function

called long a take a

message.

And in this function, we're

going to send an HTTP

request.

However, to keep things

simple here, we just want

to focus on the modularity.

We don't want to get distracted

with all the details of sending

HTTP request.

So for now, I just want to

log this message on the

console.

So console dot

log message.

OK.

Now this

variable and this log

function, they're both

scope to this module.

They're private, they're

not visible from the outside.

However, in a

OJs which is our main

module, we want to use this

log module.

So we should be able

to access this log

function.

We should be able to call

it from the APP module.

So we need to make this public,

we need to make it visible

from the outside.

Now, in the last lecture,

you saw this module object.

One of the properties we

have here is

exports, you can see this

property is set to an

empty object.

Anything that we add to this

object will be exported from

this module and it will be

available outside of this

module.

So back in our logger module,

I'm gonna set module

dot exports

dot log.

So I'm adding a method called

log to this

exports object

and simply setting it to

this log function we have

defined here.

OK.

In other words, the object

that we're exporting here

has a single method called

lock.

Now similarly, if you want

to export this URL,

we could do something like

this.

So module that

exports that

URL, we set it to

URL and of course, we could

change the name that is

exported to the outside.

For example,

internally, we may call this

variable URL.

But when we export it, we

may call it

end point.

OK.

Now, in this case, we don't

need to export this URL

variable because this is

purely implementation

detail.

So in real world applications,

every module might have

several variables and

functions, we only want to

export a subset of these

members to the outside because

we want to keep this module

easy to use.

Let me give you a metaphor,

think of a DVD player.

A DVD player has a few

buttons on the outside.

And these are the buttons

or objects that we interact

with.

So these objects represent

the public interface

of a DVD player.

OK?

But inside the box, there

are lots of other objects

or complex objects.

We don't need to know anything

about these objects, their

implementation detail and

they can change significantly

from one model to another.

But what we see on the outside

is almost stable or

static across different

models.

So in our logger module,

this URL is

implementation detail.

Other modules don't need

to know anything about this.

They only need to call the

log function.

So we export this, make it

public but keep the URL

private.

So I'm going to delete this

last line.

OK.

So we are done with our logger

module.

Now we need to load this

module and use it

inside AJ

S

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