All language subtitles for 165 Summary_ Which Array Method to Use_.en_US1

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

So, I did the math,

and since the beginning of the course,

we have studied, exactly 23 different array methods.

And that's really amazing.

And not just because,

23 is my favorite number,

but because that means,

that you cannot do everything you can imagine, with arrays.

Now, the problem is that,

choosing between 23 different methods,

is not always easy.

And especially when you just started learning about them.

Right?

So probably, in your mind right now,

there is a big confusion,

between all these methods,

and about which one to use, when.

So, to help you out with that,

I created this summary lecture,

with all the 23 array methods.

And I believe, that the best way to figure out,

which method to use,

in each situation,

is by starting to ask the question,

what do I actually want from this method?

So do I want to mutate the original array,

or do I want a new array?

Do I maybe want an array index,

or do I want to retrieve an entire array element?

Or do I want to know,

if an array includes, a certain element,

or maybe I just want to get a new string,

to transform the array to a new value,

or simply to loop over the array?

Well, these are a lot of different scenarios,

and by asking exactly these questions,

we can now categorize the methods,

and then easily choose between them.

So this is kind of a framework, that I developed,

and so let me go briefly,

through all of these different scenarios with you.

So these are the methods that mutate the original array.

So if we want to add an element,

to the original array,

we can use push or unshift.

So we already talked about all of these methods,

so of course I will not explain them again,

this is just a reference for you to keep.

Now anyway, if we want to remove,

from the original,

then we use either,

pop, shift or splice.

And finally, we also talked about,

three other methods that mutate the original array,

which is the reverse, sort and fill methods.

Okay.

So keep in mind, that you have to be careful,

because they do change the underlying array,

that we're working with.

And that many times is not what we want.

So if instead, we want a new array,

then we can use one of these methods.

So if we want to calculate one array,

from the original, then we use map methods.

And this one we use all the time,

as it loops over the original array,

and creates a new one, based on that.

We can also create new arrays,

by filtering for a condition,

or by taking a slice of the original array.

We can also concatenate two arrays,

and create a new array based on that,

and finally, we can flatten the original array,

using flat and flatMap.

Next, sometimes we need an array index.

And for that,

we have the indexOf and findIndex methods.

Now the difference between them,

is that findIndex can basically search,

for an element in the array,

based on a test condition,

that we provide, in the callback function.

But besides that,

they are pretty similar,

and both give us the index,

of a certain element in an array.

Now, if we actually need the array element itself,

then we use, the find method.

And so this one again,

is based on a test condition,

specified in a callback function.

Next up, sometimes it's very important to know,

whether an array includes,

a certain element or not.

And for that we have,

includes, some and every.

So with includes,

we can simply test,

if an array contains a single value,

while on the other hand,

with some and every,

we can specify a condition,

based on a callback function.

So some is gonna return,

if at least one of the elements in the array,

satisfies the condition,

and every, only returns true,

if all of the elements,

satisfy the condition.

So these three methods,

are all return Boolean values,

which is very helpful,

in a condition.

For example, in an if/else statement.

Okay. So that's where you many times will use,

one of these methods.

Next up, sometimes we want to transform an array,

into a string.

And then we use the join method.

Or we might want to reduce the entire array,

to just one value.

And as we already know,

for that, we use the reduce method,

just as we studied in this section.

So in the reduce method, we use an accumulator,

which has like a snowball,

to boil down, an entire array,

to just one single value.

And that value can be of any type.

So it can be a number, string, Boolean,

or even an array or an object.

All right?

And so in fact, we could,

replace some of these methods that we have here,

with a reduce.

Now, if all we want to do,

is to just loop over an array,

without producing any new value,

we use the, forEach method.

So remember, this one does not create a new array,

and in fact, it doesn't create any new value.

All we do in the forEach method is to,

basically just do some work,

but not produce a new value.

All right? And that's it.

That's an overview of all the 23 methods,

that we can use on arrays.

And it might be a good idea,

to somehow keep this overview handy.

For example, print it out on a paper,

or just store it somewhere, on your computer.

Anyway, now all there's left to do in the section,

is to complete the final coding challenge.

So let's do that right in the next video.

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