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.
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.
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
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.
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
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).
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.
That dab in 1:31 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
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.
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.
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?!"
Behind all the RUclipsrs and behind RUclips itself are people that grinded it out in higher education. Don't get too high on the education bashing juice.
@@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.
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.
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
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.
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?
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 ......?
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
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.
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.
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");
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.
Yeah, same as .bind(this) on a normal function.
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.
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
Gotta keep those arrows out of object key-value statements that use "this"....right?
but what does that actually mean?
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.
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.
I never knew programming could even be like this! This is incredible!
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
honestly your videos are awesome 20 mins tutorial feels like 5 mins... thanks!!
especially when you watch them at 1.75 speed (like I do)
so true I love the enthusiasms!
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!!!
"A function that expects a function as a parameter, creates a function and/or returns a function." - this did it for me. Thank you!!!
I was a bit confused at first but you tied it all together nicely with the doubler tripler functions. Nice work.
You are the best! You solve my questions about high-ordered functions!
You are so awesome to watch. I have a ton of fun and laugh a lot just tuning into your videos!
You are a great teacher. I always come here when there's something I can't understand. :)
I finally subbed after this one. I finally understand whats going on with ES6 and callbacks.
You are great, your entertaining skills while teaching are outstanding
Wasn't too sure how higher order functions worked but came across this video and it explained it very clearly. Thank you!
This is the best explenation of higher order functions that i seen... Only now i understand it after so many watched tuturials... Thank you!!! 👍
The best coding teacher! Thank you so much!!
Love your videos mate, super helpful and really enjoyable to watch. Thank you!
Yours are the very best tutorials, you give really good quality education here, thank you very much sir.
You can take it even further:-
const multiplier = factor => x => x*factor;
although readability can suffer a bit.
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).
I'd can keep a set of curly braces around the inner function.
Thanks I'm new to these arrows too so this has really helped!
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.
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!
Your videos are useful not only for javascript, i really appreciate
Yes. An explanation should be like this.
Thank you for this amazing explanation!
argh thank you so much for this video, explained it so much better then the current ebook I'm working off
That dab in 1:31 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
that was definitely not a dab tho :P
I learned this for swift a while ago, good video :)
That's quite relevant... Especially since I always get headache from those higher order functions!! 🙃⚫
Thanks for the video!
Coding Train for clear concise explanation.
thank you!, very well explained
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.
soooo gladdd I find you
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.
this guy has to be the most likeable person i've come across on YT
i really like your funny way and expressions to explain things.
You're great as you always 😘
thank you so much for this toturiale
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?!"
thanks for the great video....
Great tutorial
Thanks for this video
awesome !! I really like this videos
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
Behind all the RUclipsrs and behind RUclips itself are people that grinded it out in higher education. Don't get too high on the education bashing juice.
hey thanks for this!
Awesome!!!! ive been waiting for stuff like this for a looong time!!! :) . can u pease do more functional programming stuff? thanks!!!!
damn! I just subscribed and enjoy how you present this!
thank u so much for this video ^_^ u made it very entertaining
OH MY GAWD IT MAKES SENSE NOW
It crazy how entertaining you make coding. Your energy literally seeps through the screen.
"literally"? Your screen is leaking?
Did you mean "metaphorically"?
@@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.
you are very majectic the way you teach, bahaha it works!
I like your teaching
What ide do you use for js programming?
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.
It's basically inheritance. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
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
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.
Do await and async use this higher order functions?
We all love those good old factories.
Do you have any plans on completing part 3 of the agario code challenge? Looking forward to it!
still not easy for me to understand totally... but your video is great!
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?
Let's always do good 🙏
This could do interesting things with optimization of damage calculations that include special effects being doubled.
No diminishing return on the Coding Train.
Thanks for sharing.
Tip. 10:00. Don't lift your hand too much higher than the green-screen!
😭🥺rll appreciate this viddddd
Everything between () will recognise as function argument and will return as a constant variable
Amazing
11:30
const multiplier = factor => x => x * factor;
:)
Dan will you make a playlist separate for functional programming please
7:25 me whenever I see food.
thank u thank u thank u
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.
Thanks for the tip!
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 ......?
I've done this in Lua
The code executed is 4 x 2 right? not 2 x 4 isn't? at 15:10
what is the different between closure and higher order function? newbie here
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
Cool!
Can get even more cryptic if you want... let multiplier = factor => x => x * factor;
const multiplier = factor => x => x*factor, all in one line
Nice
hahaha you are awesome!
I love your voice.
If You haven't already, then try watching Daniel's videos in 1.5x speed (or even more). It's quite funny 😂.
I do 1.75x :)
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.
arrow function dont requried return value r we need to return the value
The arrow functions look like python lambdas
Because it is lambda xd
like a couple others below I'm a little confused how JS knows to pass doubler or trippler to the x variable.
@@Dima1415 Thanks!
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.
So is the arrow function like a lambda expression in Java?
indeed!
The Coding Train Thanks!
i cant seem to process the code in the example at my vs code
Good morning
applying this to multiplier function itself, it looks like this: const multiplier = factor => x => x*factor
thanks for this tip!
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");
Hello sir and viewer,
Can u explain me how multiplier(3)(5) gives out 15
ie. calling HOC( )( )
Becasue multiplier(3) returns a function which you immediately call with the argument 5.
passing function to function or returning a function is called higher order function right
correct!
please show us a useful example which we can't achieve without a higher order function!
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.
he sets the value for x when he calls the function in console
This kinda coding looks like a movie Inception damn