panzerdp / dmitripavlutin.com-comments

7 stars 0 forks source link

javascript-higher-order-functions/ #143

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

What are Higher-Order Functions in JavaScript?

The higher-order function accept as arguments or return other functions.

https://dmitripavlutin.com/javascript-higher-order-functions/

santiagodiazl commented 3 years ago

hi Dmitri, great post as always. I'd say that a built in function that could replicate your higher order function calculate() is the Array.reduce function.

Thanks for sharing!

ta5n commented 3 years ago

Hi Dimitri, Brief and to the point article. Btw is there a typo (missing invocation parentheses) below code?

doubles; // [2, 4, 8]
// it should be doubles() 

Regards

panzerdp commented 3 years ago

hi Dmitri, great post as always. I'd say that a built in function that could replicate your higher order function calculate() is the Array.reduce function.

Thanks for sharing!

Hi @santi-diazl! Thanks!

You're right, calculate() is similar to array.reduce().

panzerdp commented 3 years ago

Hi Dimitri, Brief and to the point article. Btw is there a typo (missing invocation parentheses) below code?

doubles; // [2, 4, 8]
// it should be doubles() 

Regards

Thanks @me-tasosman! The typo has been fixed.

vipinc007 commented 3 years ago

Great Article. Thanks for writing this simple and effective post. It gave me a good clarity about higher order function.

panzerdp commented 3 years ago

Great Article. Thanks for writing this simple and effective post. It gave me a good clarity about higher order function.

That's great @vipinc007!

AliN11 commented 3 years ago

Great explanation Dmitri. calculate function could be written with reduce method. Good luck 💪

panzerdp commented 3 years ago

Great explanation Dmitri. calculate function could be written with reduce method. Good luck muscle

Thanks @AliN11. Yes, calculate is equivalent to array.reduce.

dovhanrg commented 3 years ago

Чувак, ты крут, спасибо) Хорошо и просто пишешь) Можешь еще про Компоненты высшего порядка рассказать? и про карирование)

stephen-oconnor commented 3 years ago

Nice write-up Dmitri. I read all your blog posts and always come out having learned something new. Keep up the good work.

panzerdp commented 3 years ago

Nice write-up Dmitri. I read all your blog posts and always come out having learned something new. Keep up the good work.

Thanks @stephen-oconnor! I'm glad you're always learning something new from my posts.

ses3332002 commented 3 years ago

Hi! Thank you for your work :) I guess, in line "So, in JavaScript a function can be either first-order or high-order" it is better to use "higher-order" definition, not "high-order".

panzerdp commented 3 years ago

Hi! Thank you for your work :) I guess, in line "So, in JavaScript a function can be either first-order or high-order" it is better to use "higher-order" definition, not "high-order".

Thanks @ses3332002! You're right about "high-order" — I made a fix.

nicole929chan commented 2 years ago

Hi, Thank you for this great post, the calculator example makes me a little understand what HOF is. Could you give more example about C, return functions from functions? I couldn't figure out what context will use it? Thank you very much.