All language subtitles for 009 Objects, their Methods and the Dot Notation.en

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
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

Now what about methods? Let's say that our bellboy is able to do something called moveSsuitcase.

Now, I've kind of simplified it here, but it's effectively, he creates an alert saying "May I take your

suitcase?",

and then he picks up the suitcase and then he moves with the suitcase.

Now this is a function because at the moment it's not attached to an object but in our previous syntax

if we wanted our object to also have an associated function, then all we have to do is provide the name

of the function as a new parameter,

and then colon, and then after the colon we just put in the anonymous function.

And now our bellBoy1 has a method, which remember is just a function that's associated with an object.

And if we had a suitcase in the lobby then we can simply call the method and say bellBoy1.moveSuitcase(),

and perform that method.

So remember that when we're using the properties or calling a method we're always using the dot notation.

And the only difference that you see between the method and the property are those parentheses,

so keep an eye out for those.

Now if we wanted to incorporate this method into our constructor function then all we have to write

is

this.moveSuitcase is equal to a function that does these and these things.

And now when we create any object using this constructor function, then all of those objects will have

that function of moveSuitcase, and they'll all be able to do that.

So as a challenge I want you to add a method to our HouseKeeper constructor function,

and this method is just called clean, so that we can get the housekeeper to perform the clean function.

And we're going to do it in a simplified way so that our method of what it does is sends an alert that

says "Cleaning in progress".

So add that to the constructor function,

create a new housekeeper from that constructor function, and call the cleaning method associated with

that new object.

So pause the video now and see if you can complete this challenge.

All right.

So as we said before to create a new method or a new property, we first have to start with this.the name

of the property or method.

So our method is called clean and it's not equal to just any value but it's equal to a function and

this function, as we said before, has to send an alert that says "Cleaning in progress".

So now that we've got our method associated with our HouseKeeper constructor function, then we need to

create new objects that have this method.

So let's go ahead and again empty cache and hard reload, and let's run our new code, and then let's create

a new object called houseKeeper1, which is equal to a new HouseKeeper, which has 12 years experience,

he's called James, and he's only qualified to clean bedrooms.

All right. So now let's hit enter and create our new object called houseKeeper1.

Now houseKeeper1 now comes equipped with this method called clean.

So we can simply say houseKeeper1.clean.

And if we hit enter you can see that we get an alert that says "Cleaning in progress". Pretty good, right?

Now at this point you might be getting a little bit of deja vu because it's looking pretty similar to

something that we've written before.

It looks almost exactly the same as these lines of code that we used to create a new audio

and to play the audio, because we created a new variable that was called tom1,

and it's a new audio object that is linked to this particular sound file,

and then later on we used that object's method called play to play that sound.

So even though we can't see the source code of this constructor function, but we could guess what it

might look like.

So the constructor function for this audio object might look something like this.

So, as with all constructor functions, you start off with the keyword function and then you have the

name of the object that it's going to construct with the first letter capitalized and then in between

some parentheses we have some inputs.

And in this case it's going to be the location of the file for that audio.

So now our constructor makes a new property called file location which is set equal to the location

that was given when this new audio object gets created.

And then this constructor function also has an associated method called play,

and this play function does a number of things,

for example it might tap into the audio hardware of the computer,

it might check whether the file at the file location specified exists,

it might check that the file is actually a sound file, and then it might try and play that file at that

location.

And all we had to do was to use that constructor Audio to create a new audio object specifying the

location of our audio file,

then we simply called the method that was associated with that new audio object and got it to play that

sound.

Now a lot of the code that you'll be writing in Javascript involves using these properties and methods

associated with the objects on your web site, and occasionally you also need to create your own objects

in order to get some custom behavior on your web site.

Now hopefully this lesson has helped you to understand what we've been writing

when we created our audio objects and when we called our methods or when we used our properties in our

drumkit web site. Now a lot of these concepts are quite abstract and it might take a little bit of repetition

and coming back to it a few times in order for it to start making more sense.

But as with all things programming as we get more practice using a lot of these concepts over time it

will become more and more familiar to you and the puzzle pieces will start coming together.

So don't worry if some of this stuff is going over your head. We're going to be revisiting this in the

future

as we keep building more and more web sites. But this is a great place to just sow the seeds about objects

in Javascript, and hopefully you'll revisit this lesson a few more times and eventually getting really

comfortable with this concept.

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