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
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
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
In the last section, we put together our cards with suit method and we made special use of the wear
function that is included with every list automatically in the section.
We're going to do a very small refactor to this function right here to make use of an abbreviated syntax
for defining functions.
So I want you to notice right now that when we call where we passed in a function that gets called one
time for every element in the array, and we used what is referred to as the long form function syntax
right here, the long form function syntax makes use of these curly braces.
And we also had the return statement in there as well.
Notice how the body of our function really just has one single expression inside of it in a single expression,
just looks at one property and compares it to another.
So this is one single expression.
Because we have one expression inside of here, we can use a slightly abbreviated syntax for defining
this function, so we're going to do the refactor and we'll talk about the differences between the two.
So I'm going to first get started on this refactor by removing the semicolon.
I'll then remove the return statement and I'll put all this stuff on one line.
Like so.
I'll then remove this curly brace on the right hand side, and then I will replace the curly brace on
the left hand side with an equal sign and a greater than sign like.
So oops did not mean to click that.
There we go.
So what we have on the screen right here is completely equivalent to what we had before, so because
we had one single expression, we can make use of this arrow function syntax.
If we had multiple expressions or multiple lines of code, we could not use the abbreviated syntax.
The other thing I want to make clear is that when we use this arrow, we get what's called an implicit
return.
So whatever this expression right here evaluates to will be automatically returned from the function
before us when we had the long form syntax with the curly braces like so we had to manually put in a
return statement.
So because we had a single expression and we made use of the Arrow syntax, we got an automatic return
for free.
So if I now run this code again, you'll notice that I get the same result up here on the top, right,
just like I did before.
We're going to be making use of this abbreviated syntax quite a bit throughout this course and will
sometimes also swap off back to that longer form syntax any time we need to have multiple expressions
inside of our function body.
So we're going to see the syntax quite a bit both ways.
All right.
So we've got a good reflector here.
Let's continue in the next section.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.