DEV Community

Cover image for JS interview in 2 minutes / Higher Order Functions

JS interview in 2 minutes / Higher Order Functions

Nick K on April 26, 2021

Question: Explain Higher Order Functions in Javascript. Quick answer: These are functions that return other functions. UPD: as @mazentouati noted...
Collapse
 
mazentouati profile image
Mazen Touati

Nice read Nikita!

It would be more insightful to clearly state that Higher Order Function should meet one of these conditions or both of them:

  • It returns a function
  • It accepts at least one function as a parameter (Like reduce that's being used in the example).
Collapse
 
kettanaito profile image
Artem Zakharchenko

Yeap, that's completely true. The original short definition:

These are functions that return other functions.

Should be changed to something like:

These are functions that accept a function as an argument or return other functions

Collapse
 
hexnickk profile image
Nick K

Hey, thanks for the comment!

That's totally right, needed to double-check the definition, my bad. I've added an update note with a mention to the second section πŸ™

Thanks again!

Collapse
 
johnny_ness profile image
pheeno

awesome! the most easy way to learn about high order function !

Collapse
 
hexnickk profile image
Nick K

Glad you like it ✨

Collapse
 
midasxiv profile image
Midas/XIV

Good read! :D

Collapse
 
hexnickk profile image
Nick K

Thanks! ⭐️