Тёмный

16.5: Higher Order Functions in JavaScript - Topics of JavaScript/ES6 

The Coding Train
Подписаться 1,7 млн
Просмотров 152 тыс.
0% 0

In this video, I discuss "higher order functions" in JavaScript.
🎥 Next Video: • 16.6: Array Functions:...
🎥 Topics of JavaScript/ES6: • 16: Topics of JavaScri...
🎥 ES6 Arrow Function: • 16.3: ES6 Arrow Functi...
🎥 Closures in JavaScript: • 9.6: JavaScript Closur...
🚂 The Coding Train website: thecodingtrain.com/
💖 Support this channel on Patreon: / codingtrain
🛒 To buy Coding Train merchandise: www.designbyhumans.com/shop/c...
📚 Book recommendations: www.amazon.com/shop/thecoding...
💻 github.com/CodingTrain/Rainbo...
🎥 For an Introduction to Programming: • Start learning here!
🎥 For More Coding Challenges: • Coding Challenges
🔗 p5js.org/
🔗 processing.org
📄 Code of Conduct: github.com/CodingTrain/Code-o...

Опубликовано:

 

18 фев 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 193   
@lolulol4
@lolulol4 6 лет назад
The syntax is not the only difference between arrow and regular functions. An arrow function does not create its own context, while regular ones do. This is something important to keep in mind.
@POGOLAUNCHER
@POGOLAUNCHER 6 лет назад
Yeah, same as .bind(this) on a normal function.
@TheCodingTrain
@TheCodingTrain 6 лет назад
Yes, this is key! Thank you for the comment. I wish I had mentioned this during the video. I do discuss this aspect in my arrow functions video. Will pin this comment so others see.
@lolulol4
@lolulol4 6 лет назад
POGOLAUNCHER while that is one of its benefits and gives somewhat of the same result, I wouldnt say it's exactly the same. It can also get you results you dont want
@guinwhite
@guinwhite 4 года назад
Gotta keep those arrows out of object key-value statements that use "this"....right?
@adityadubey5204
@adityadubey5204 3 года назад
but what does that actually mean?
@iTzJimBoi
@iTzJimBoi 3 года назад
How you can remain engaged and ENGAGING throughout your videos is a skill I'm highly jealous of. You take a screen full of code and humanize it. I'm currently stuck in class trying to prove higher order functions work by rewriting them in our own words...and it's not fun. It's basically .filter() my joy out of my personal array. Your channel is a gushing spring river on a hot summer's day.
@keving6758
@keving6758 3 года назад
his enthusiasm is what every other programmer needs on their tutorial videos. Literally if other people were like this, i would of learned java so much faster
@jw7665
@jw7665 5 лет назад
Usually I have to speed the video up, but this time I slowed it down a bit lol. Dudes a ball of energy, makes a great teacher.
@zinsy23
@zinsy23 4 года назад
I never knew programming could even be like this! This is incredible!
@juanok2775
@juanok2775 5 лет назад
honestly your videos are awesome 20 mins tutorial feels like 5 mins... thanks!!
@guinwhite
@guinwhite 4 года назад
especially when you watch them at 1.75 speed (like I do)
@adityadubey5204
@adityadubey5204 3 года назад
so true I love the enthusiasms!
@neonhoshi
@neonhoshi 2 года назад
Thank you for this video!!! I have read and read my lesson over and over, but after coding along with you it finally made sense!!!
@Momosun2018
@Momosun2018 4 года назад
"A function that expects a function as a parameter, creates a function and/or returns a function." - this did it for me. Thank you!!!
@techtronixweb7040
@techtronixweb7040 5 лет назад
I was a bit confused at first but you tied it all together nicely with the doubler tripler functions. Nice work.
@noahbrewer8611
@noahbrewer8611 3 года назад
You are so awesome to watch. I have a ton of fun and laugh a lot just tuning into your videos!
@MalikJamazov
@MalikJamazov 4 года назад
You are the best! You solve my questions about high-ordered functions!
@joeekadi
@joeekadi 2 года назад
Love your videos mate, super helpful and really enjoyable to watch. Thank you!
@katherinedragieva
@katherinedragieva 4 года назад
You are a great teacher. I always come here when there's something I can't understand. :)
@danielrodas7692
@danielrodas7692 2 года назад
Wasn't too sure how higher order functions worked but came across this video and it explained it very clearly. Thank you!
@christopherholt3782
@christopherholt3782 2 года назад
this guy has to be the most likeable person i've come across on YT
@santiagoramirez5507
@santiagoramirez5507 3 года назад
The best coding teacher! Thank you so much!!
@percy888ferry
@percy888ferry 6 лет назад
You can take it even further:- const multiplier = factor => x => x*factor; although readability can suffer a bit.
@jkf16m96
@jkf16m96 2 года назад
const multiplier = factor => number => number*factor; I think just changing "x" with "number" might be readable enough (unless the reader doesn't know arrow syntax).
@gabef9538
@gabef9538 2 года назад
I'd can keep a set of curly braces around the inner function.
@davidmcdougald6695
@davidmcdougald6695 6 лет назад
I finally subbed after this one. I finally understand whats going on with ES6 and callbacks.
@darkthrongrising5470
@darkthrongrising5470 6 лет назад
Yours are the very best tutorials, you give really good quality education here, thank you very much sir.
@danilo86petrovic
@danilo86petrovic Год назад
This is the best explenation of higher order functions that i seen... Only now i understand it after so many watched tuturials... Thank you!!! 👍
@WistrelChianti
@WistrelChianti Год назад
Thanks I'm new to these arrows too so this has really helped!
@jetspray3
@jetspray3 3 года назад
Coding Train for clear concise explanation.
@hugodelnegro
@hugodelnegro 5 лет назад
You are great, your entertaining skills while teaching are outstanding
@kopilkaiser8991
@kopilkaiser8991 2 года назад
I enjoy watching your energy and interest in explaining programming logic. You have helped me understand this concept easier. I have tried reading many articles and forums for understanding Higher Order Functions but couldn't grasp the idea of it. But, you have helped me understand it better. Thank you so much for giving such efforts in explaining the complex ideas. Keep it up. I've subscribed to your channel to follow you regular.
@blusanders
@blusanders 3 года назад
These are new to me and hard to wrap my brain around just yet but this is the best explanation thus far for me :) Thanks!
@Locationary
@Locationary 5 лет назад
argh thank you so much for this video, explained it so much better then the current ebook I'm working off
@elgary9074
@elgary9074 3 года назад
Thank you for this amazing explanation!
@Nyamistaya
@Nyamistaya 6 лет назад
Your videos are useful not only for javascript, i really appreciate
@papii_6669
@papii_6669 6 лет назад
I learned this for swift a while ago, good video :)
@thedotisblack
@thedotisblack 6 лет назад
That's quite relevant... Especially since I always get headache from those higher order functions!! 🙃⚫ Thanks for the video!
@cnsnmms3708
@cnsnmms3708 4 года назад
Yes. An explanation should be like this.
@Dylan_thebrand_slayer_Mulveiny
What's crazy is you could also do const multiplier = factor => x => x * factor In fact, if you wanna get extra crazy, you can keep nesting the pattern as far as you want. I seriously love JS.
@ore_bear8045
@ore_bear8045 3 года назад
thank you!, very well explained
@RodrigoCastroAngelo
@RodrigoCastroAngelo 6 лет назад
That dab in <a href="#" class="seekto" data-time="91">1:31</a> was flawless! Also, I don't remember where I saw it, something about functional programming I guess, but they had a similar example: You have a function multiply(a,b) with two argments. If you call multiply(2,3) it returns 6 But you can also call multiply(2) which returns a function like that doubler, which multiplies to 2 whatever you pass in to it
@sadhlife
@sadhlife 6 лет назад
that was definitely not a dab tho :P
@ginalin310
@ginalin310 5 лет назад
soooo gladdd I find you
@mistermomo2904
@mistermomo2904 4 года назад
I'm still in high school, but i get the sensation that i'd learn more from this guy in 16 minutes than a professor in hours
@youtubezcy
@youtubezcy 3 года назад
Behind all the RU-vidrs and behind RU-vid itself are people that grinded it out in higher education. Don't get too high on the education bashing juice.
@yavasel
@yavasel 4 года назад
Hello, mate. Thank you very much. You are very good on this. This is the best coding video I have ever watched. I wish I could contribute you doneting this beautiful video but l lost my job 2 weeks ago because of covid.
@lukes5631
@lukes5631 Год назад
It crazy how entertaining you make coding. Your energy literally seeps through the screen.
@dgh25
@dgh25 Год назад
"literally"? Your screen is leaking? Did you mean "metaphorically"?
@lukes5631
@lukes5631 Год назад
@@dgh25 No. I mean literally because he is an exceptional and embodied communicator whose energy you can FEEL through the screen you dunkin' donut head.
@adamnorman85
@adamnorman85 2 года назад
You're great as you always 😘
@mssadewa
@mssadewa 4 года назад
damn! I just subscribed and enjoy how you present this!
@okoiful
@okoiful 6 лет назад
Awesome!!!! ive been waiting for stuff like this for a looong time!!! :) . can u pease do more functional programming stuff? thanks!!!!
@juliancaste3914
@juliancaste3914 5 лет назад
awesome !! I really like this videos
@Weeb940
@Weeb940 Год назад
thank you so much for this toturiale
@fdj1966
@fdj1966 2 года назад
thanks for the great video....
@phantasmFES
@phantasmFES 5 лет назад
thank u so much for this video ^_^ u made it very entertaining
@rnmmakings4989
@rnmmakings4989 6 месяцев назад
i really like your funny way and expressions to explain things.
@aayanguren
@aayanguren 3 года назад
Honestly watching you make the same (minor) mistakes I make, makes me feel a lot better about my experience learning code. Except, I spend thirty minutes questioning everything I've learned studying functions, before realizing I forgot the second "i" in multiplier. "Like what the? I thought I understood this!!! What happened?!"
@chrismanuel8993
@chrismanuel8993 5 лет назад
hey thanks for this!
@stuffedpeanuts
@stuffedpeanuts 2 года назад
Great tutorial
@manu_prasadh
@manu_prasadh 6 лет назад
Thanks for this video
@syedarmaghanhassan4652
@syedarmaghanhassan4652 3 года назад
Thanks for sharing. Tip. <a href="#" class="seekto" data-time="600">10:00</a>. Don't lift your hand too much higher than the green-screen!
@fuzzylilpeach6591
@fuzzylilpeach6591 5 лет назад
OH MY GAWD IT MAKES SENSE NOW
@mainlandbahr2176
@mainlandbahr2176 3 года назад
How does the doubler(x) call work when there are no parenthesis holding parameters in the definition let doubler = mutiplier(2); I saw a comment below that mentions inheritance in JS, but I was still unable to make sense of this as it looks implied and not defined.
@Suviiii69
@Suviiii69 6 месяцев назад
😭🥺rll appreciate this viddddd
@JonatanEdOrtiz
@JonatanEdOrtiz 4 года назад
Amazing
@gabef9538
@gabef9538 2 года назад
This could do interesting things with optimization of damage calculations that include special effects being doubled.
@ynotbutcher1891
@ynotbutcher1891 4 года назад
you are very majectic the way you teach, bahaha it works!
@trex283
@trex283 5 лет назад
What ide do you use for js programming?
@user-bx9pj9lc4x
@user-bx9pj9lc4x 4 года назад
I like your teaching
@mohammadalrefaai-games8034
@mohammadalrefaai-games8034 4 года назад
thank u thank u thank u
@BeKindPlox
@BeKindPlox 6 лет назад
Cool!
@CharlesGouin
@CharlesGouin 6 лет назад
We all love those good old factories.
@Mari_Selalu_Berbuat_Kebaikan
Let's always do good 🙏
@jakefreise7601
@jakefreise7601 6 лет назад
Do you have any plans on completing part 3 of the agario code challenge? Looking forward to it!
@amogus7
@amogus7 3 года назад
Everything between () will recognise as function argument and will return as a constant variable
@papinkelman7695
@papinkelman7695 6 лет назад
No diminishing return on the Coding Train.
@ErrorDebug
@ErrorDebug 4 года назад
Hi thanks for your videos you are awesome healthy guy! I have one question cus i am a beginner, I see this first time, how can you pass a number into a variable 'doubler(4)' and that variable knows that you are referring to returned x parameter??? How and why it knows that, how is that linked?
@frankrizzo5181
@frankrizzo5181 4 года назад
I accidentally set the tripler factor to 4 and when changing it to three I got an error telling me identifier tripler had already been declared. It's a "let" declaration ......?
@setupdraw7642
@setupdraw7642 6 лет назад
Nice tutorial but I think it is not 100% clear (at least to me) how "x" argument is handled by the function; where the "x" parameter comes from (where it gets defined as a variable) and how it is passed in the factory function.
@Dylan_thebrand_slayer_Mulveiny
It's basically inheritance. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
@4ipon4ik
@4ipon4ik 3 года назад
function multiplier(factor){ return x => x * factor; } let doubler = multiplier(2); // now doubler = x => x * 2; // so doubler(4) returns 4 * 2; // doubler assigned multipliers returned function
@ninglizhu2255
@ninglizhu2255 5 лет назад
still not easy for me to understand totally... but your video is great!
@darsh_shukla
@darsh_shukla 4 года назад
Dan will you make a playlist separate for functional programming please
@saminchowdhury7995
@saminchowdhury7995 4 года назад
<a href="#" class="seekto" data-time="445">7:25</a> me whenever I see food.
@anmolagarwal5952
@anmolagarwal5952 4 года назад
Do await and async use this higher order functions?
@wreak3r
@wreak3r 6 лет назад
Also just in case you come across this syntax, you may call the multiplier function like so: multiplyer(2)(4) and get 8 as result.
@TheCodingTrain
@TheCodingTrain 6 лет назад
Thanks for the tip!
@aleksandrstaetskiy5687
@aleksandrstaetskiy5687 4 года назад
Nice
@mekelilyasa9561
@mekelilyasa9561 2 года назад
what is the different between closure and higher order function? newbie here
@denzelsugayan432
@denzelsugayan432 3 года назад
i cant seem to process the code in the example at my vs code
@VimalKumar-dl5jb
@VimalKumar-dl5jb 6 лет назад
arrow function dont requried return value r we need to return the value
@amirulidzham3686
@amirulidzham3686 5 лет назад
The code executed is 4 x 2 right? not 2 x 4 isn't? at <a href="#" class="seekto" data-time="910">15:10</a>
@Solsenderz
@Solsenderz Год назад
Well, I thought I could teach myself what is hof in the video, but instead, I'm more confused now, lol) definitely not for beginners, it's so fast to catch all of your ideas
@angelcaru
@angelcaru 4 года назад
<a href="#" class="seekto" data-time="690">11:30</a> const multiplier = factor => x => x * factor; :)
@lucasteixeiranl4473
@lucasteixeiranl4473 2 года назад
hahaha you are awesome!
@ukaszczaja9400
@ukaszczaja9400 5 лет назад
If You haven't already, then try watching Daniel's videos in 1.5x speed (or even more). It's quite funny 😂.
@sahilcoleslaw
@sahilcoleslaw 4 года назад
I do 1.75x :)
@vladthe_cat
@vladthe_cat 3 года назад
I've done this in Lua
@thebuildguy7
@thebuildguy7 4 года назад
I would agree more if someone said the father of computer science has a youtube channel named "The Coding Train", rather than memorizing his name from my GK book in first grade.
@emerson-sheaapril8555
@emerson-sheaapril8555 5 лет назад
like a couple others below I'm a little confused how JS knows to pass doubler or trippler to the x variable.
@emerson-sheaapril8555
@emerson-sheaapril8555 5 лет назад
@@Dima1415 Thanks!
@rominatulli4243
@rominatulli4243 5 лет назад
I love your voice.
@konstantinkkk8397
@konstantinkkk8397 4 года назад
does it higher order or destructuring? I cannot understand this code. Snippet where function return function function fluent(fn) { console.log(fn); return function (...args) { console.log(args); }; } function Person() {} Person.prototype.setName = fluent(function (first, last) { this.first = first; this.last = last; }); let Peter = new Person(); console.log(Peter); Peter.setName("Peter", "Parker");
@ruuji.
@ruuji. 4 года назад
So I tried shortening the whole thing up and came up with this: let add = addition => { return x => x + addition; } Same with multiple, just as an addition.
@irwinpalomo7212
@irwinpalomo7212 6 лет назад
Gracias.
@mightyocean411
@mightyocean411 3 года назад
const multiplier = factor => x => x*factor, all in one line
@brod515
@brod515 5 лет назад
Can get even more cryptic if you want... let multiplier = factor => x => x * factor;
@iandareopal
@iandareopal 6 лет назад
I do not understand what is being passed through as x in these examples, it seems as though you are only passing a value for factor.
@magdalenahlohovska1738
@magdalenahlohovska1738 5 лет назад
he sets the value for x when he calls the function in console
@mirtwomirtwo6810
@mirtwomirtwo6810 Год назад
🔥ty
@sumantkanala
@sumantkanala 6 лет назад
applying this to multiplier function itself, it looks like this: const multiplier = factor => x => x*factor
@TheCodingTrain
@TheCodingTrain 6 лет назад
thanks for this tip!
@mortyjr2334
@mortyjr2334 5 лет назад
So is the arrow function like a lambda expression in Java?
@TheCodingTrain
@TheCodingTrain 5 лет назад
indeed!
@mortyjr2334
@mortyjr2334 5 лет назад
The Coding Train Thanks!
@kantyDarius
@kantyDarius 6 лет назад
hi, i have a suggestion, you could use the extention "code runner" in your videos instead the browser.
@2600D4u
@2600D4u 6 лет назад
Good morning
@neddev2990
@neddev2990 2 года назад
Clickety, click, click.... don't mind me. I'm getting stuff that i didn't understand before! great tutorial.
@shajiabbas5342
@shajiabbas5342 3 года назад
This kinda coding looks like a movie Inception damn
Далее
16.3: ES6 Arrow Function - Topics of JavaScript/ES6
22:32
I Built 100 Houses And Gave Them Away!
09:36
Просмотров 63 млн
When You Get Ran Over By A Car...
00:15
Просмотров 8 млн
The Weird History of JavaScript
12:09
Просмотров 1,2 млн
JavaScript Higher Order Functions & Arrays
34:56
Просмотров 979 тыс.
Callback and Higher Order Functions in JavaScript
16:41
16.12: Promises Part 2 - Topics of JavaScript/ES6
11:50
Higher Order Functions - JavaScript Tutorial
10:10
Просмотров 61 тыс.
Ditch your Favorite Programming Paradigm
6:08
Просмотров 167 тыс.
16.1: let vs var - Topics of JavaScript/ES6
12:20
Просмотров 221 тыс.
Object-Oriented Programming is Bad
44:35
Просмотров 2,3 млн
16.14: async/await Part 2 - Topics of JavaScript/ES8
10:08
I Built 100 Houses And Gave Them Away!
09:36
Просмотров 63 млн