In this video series, we learn how to do functional programming in JavaScript. In this second one, I show you how and when to use the higher-order function map, and why it is the best thing ever.
Resources:
Code from the video
https://gist.github.com/mpj/c5ae804e576042b3287d
How to install and use io.js (for the arrow functions example)
36 responses to “Map – Part 2 of Functional Programming in JavaScript”
I had part 1 on max volume with headphones in because the audio is quite low. Then I played this video and you're like "HELLO!" and nearly jumped out of my seat in starbucks. LOL
So much louder than part 1 lol XD Great videos as always! thanks so much
Hi, I'm watching this from the future and don't need to do that harmony thing 🙂
That's what I was looking for, Advanced JS!!!You are an amazing teacher and you have a sense of humor at the same time.
What if I wanted to get all animals that are dogs?
cool video 🙂
great videos, why am I just learning about you. Keep up the great work. *Subscribed*
i like how he not use semi colon to end statements. I believe the JS engine do it for him
I am sorry if someone already asked or I totally miss understood the topic, but I believe the map function loops inside itself, so what the buzz about "map", it is just an extension. But the final code that executed would always be the same or more in this case.
First video to ever speak the wise words which could save newcomers time: 'if you're watching from the future you don't have to do this' 😀
So good!
var animals = [
{ name: 'Fluffykins', species: 'rabbit' },
{ name: 'Caro', species: 'dog' },
{ name: 'Hamilton', species: 'dog' },
{ name: 'Harold', species: 'fish' },
{ name: 'Ursula', species: 'cat' },
{ name: 'Jimmy', species: 'fish' }
]
You know your teacher is awesome when you look forward to coming home and playing the videos. Keep up the great work, and thank you.
Awesome the way you explained buddy
I am ginger, I have no soul… But I see beuty in this 😀
Some nice comment to MPJ,
You are the best. You make learning so easy and fun. Thank you.
'This is because arrays of animals are very common in enterprise programming'. Damn that got me good.
If you were my professor, I might of actually not dropped out of college.
It's better to use join() when printing arrays.
It appears that I'm watching this video from the future. 🙂
Nice Tutorial, you just made me to understand map() in the simplest way. Keep the good job
Functional programming done on Arrays is neat, How to do the same when you are dealing with a big object with nested objects ??
Cool 😀
YOU WIN ALL
I really really like your stuff. I always imagined myself doing something very similar to how you do it however fear struck me and I forgot to let myself be crazy like I like to be. Thanks for filling in some gaps that I have.
On the other hand, I'd like to return you a favor and let you know that:
CTRL + J (on a selection of multiple lines) will convert them in one line separated by space, more like:
lines.join(' ');
Thanks again! You're really cool.
Best teacher!!!!!!
Press 9 for the best part of the video.
yoo, this guy is so fun to watch and I am really learning things, and the best thing is that he reminds me that there are other weird and energized people out there as well 😀
Thank you for making these videos!!!!!! You truly have a gift for communicating potentially tricky concepts with such clarity. I will continue to use your videos throughout my coding journey (which began in December 2016). Thanks again!
after very long time now i began to understand u, so i also started liking ur jokes 🙂
I am watching from the future and you were right (7:40)
https://youtu.be/bCqtb-Z5YGQ?t=1m7s
"WHAT?! What does it mean?"
Good laugh!
The code above could be more interesting by using the ES6 destructuring.
var names = animals.map(({ name: n }) => n)
8:31
also it could be shorter if you remove the parenthesis from (x)
it will be like this
“`
var names = animals.map(x => x.name)
“`
I don't understand why I understand. You are amazing, hilarious. wow.