All language subtitles for 149 Data Transformations_ map, filter, reduce.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

In JavaScript,

there are three big and important array methods

that we use all the time to perform data transformations.

So basically,

these are methods that we use

to create new arrays based

on transforming data from other arrays.

And in recent years,

these tools have become really popular and for good reasons

and therefore you'll see them everywhere you look

in Modern JavaScript.

And the tools I'm talking about are; map, filter and reduce.

So these are three array methods

and in this lecture,

I'm gonna give you a quick overview of them.

Then over the next couple of lectures,

we're gonna dive deep into these three methods

in practice so that we can use them

throughout the rest of the course.

First the map method is yet another method that we can use

to loop over arrays.

So, map is actually similar

to the forEach method that we studied before

but with the difference that map creates a brand new array

based on the original array.

So essentially the map method takes an array,

loops over that array

and in each alteration,

it applies a covic function

that we specify on our code

to the current array element.

So in this example we say that each element

shall be multiplied by two.

And with this covic in place,

the map method multiplies every single element by two

and puts it into a new array.

We say that it maps the values of the original array

to a new array and that's why this method is called map.

And it is extremely useful.

Usually way more useful than in forEach method

because forEach simply allows us to do some work

with each array element.

But map on the other hand,

builds us a brand new array

containing the results of applying an operation

to the original array,

all right?

And we will use the map method

in practice right in the next video.

Anyway,

next up we have the filter method,

which as the name says, is used to filter for elements

in the original array which satisfy a certain condition.

So in this example we are only looking

for elements greater than two.

So all the elements that pass the test

that we specified will make it into a new filtered array.

Or in other words elements for which the condition is true

will be included in a new array

that the filter method returns.

All other elements will get filtered out

so they will not be included in the new array.

And finally there is also the reduce method

which we use to boil down all the elements

of the original array into one single value.

And an example of this can be to add all the elements

of an array together.

But we can also do many other interesting things.

So for the example of adding up all numbers in the array,

we need to specify an operation like this one

where we have an accumulator variable.

Then as the reduce method loops over the array,

it keeps adding the current element onto the accumulator

until at the end of the loop we have

to total sum of all the elements.

So you can imagine this as a snowball,

it keeps getting bigger and bigger

as it rolls down a hill.

And so this is known as the snowball effect

and reduce is pretty similar to that,

okay?

So keep that in mind as a nice analogy.

Now we also said that this whole process

has now reduced the original array to one single value

which in this case is the sum of all the elements

but it can of course be many other operations.

Now it's this value that then actually gets returned

from the reduce method in the end.

So there is no new array in this case

but only the reduced value.

Now this probably sounds more complicated

than it actually is.

And so let's start to put it

into practice 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.