In this video we will look at some of the very powerful higher order functions and working with arrays. We will look at forEach, map, filter, reduce and sort.
SPONSOR:
https://www.bugreplay.com
MODERN JAVASCRIPT FROM THE BEGINNING ($10 PROMO):
https://www.udemy.com/modern-javascript-from-the-beginning/?couponCode=YOUTUBE10
CODE: JSFiddle
https://jsfiddle.net/bradtraversy/e5rb0x0a/
💖 BECOME A PATRON: Show support & get perks!
http://www.patreon.com/traversymedia
VISIT MY WEBISTE: Check Out My Udemy Courses
http://www.traversymedia.com
FOLLOW TRAVERSY MEDIA:
http://www.facebook.com/traversymedia
Tweets by traversymedia
http://www.instagram.com/traversymedia
https://discord.gg/traversymedia
Original source
22 responses to “JavaScript Higher Order Functions & Arrays”
Thank you very much for this proper explanation! Just one bit of feedback; at some moments you excuse the listener for the noise in the background. It's only because you're saying it that I'm noticing it. It seems like the one who's bothered most about it is you. The quality of your content of good so don't worry about it :).
Many thanks, the was really helpful
If you want to scare Brad, just let him write couple of times a word "companies" :). Thanks for amazing video Brad, always love your work.
7:53
You can still make the code less without using if statement and the fat arrow function.
Instead of :
const canDrink=ages.filter(function(age){
if(age>=21){
return true;
}
});
console.log(canDrink);
You can use:
const canDrink= ages.filter((age)=>{
return age>=21; });
console.log(canDrink);
Hi Brad , please update the modern JS course on Udemy … adding this stuff and functional programming as well will be very nice and usefull ! Thanks bro
Thanks for incentivize us to try writing it ourselves. I know I could do that in any video, but I usually forget and just watch the whole thing.
One more thing: I do really like this less hands-on videos because this way we can better understand methods and syntax, and how to do things on our own (which is very important).
I don't mean that the follow-along vids are not good! They also are… I guess a 50-50 mix of both is best in my book (or 60% practice, 40% explanations perhaps)…
I find that on my level, when you are going from beginner to intermediate, one of the challenges we find is to be daunted when we have to complete projects without following along, because we thought we knew something but in reality we have no idea where to start when we have to implement and no-one is there to hold our hands…
Hi Brad, you are too awesome (and I don't say it to be slimey cause I hate that, but credit is due when due, and here it is due…).
My question is: you mention you'd add some more content on the ´higher order functions´to your Modern JS Course in Udemy. I was looking into buying this course for a while (impediment until now being the perceived lack of time to follow it…), and if this was explained in more detail there it'd make it even more interesting and raise it above on my list of courses to buy and follow.
Thank you again, your help is invaluable as always <3
L. (a female programmer in da making)
respect from Pakistan.
What is i?
You are the truth!
Can anyone explain to me why the sort returns 1, else -1? How would that result in the companies being sorted?
Can anyone explain to me why the sort returns 1, else -1? How would that result in the companies being sorted?
if you're using a function without doing anything special with it you don't need to wrap it in an anonymous function. e.g.
const squareAges = ages.map(Math.sqrt);
Thank you so much. Your explanation was amazing. lovely!
const sortedArray = array.sort() is manipulating my original array as well as the sortedArray constant. How do I keep from changing my original array?
Thanks for this wonderful lesson 🙂
what does return 1 and return -1 do ? please explain the process of sorting.
Amazing. Thanks for such useful tricks
I really like this video, very helpful. I tried to replicate it in Atom but I received the following error: "W104 – 'const' is available in ES6 (use 'esversion: 6) or Mozilla JS extensions (use Mozzarellas). I have come across this several times and I don't understand what I need to do. (I am just learning – please help if you can,). Ronald.hirshauer@gmail.com. TY
I love your tutorial, please keep making new videos
guys i wanna know what that dollar sign does $`