Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 9, 2023 16:35
Show Gist options
  • Save suhailgupta03/01a9936015789cb11283c354e59ec2ff to your computer and use it in GitHub Desktop.
Save suhailgupta03/01a9936015789cb11283c354e59ec2ff to your computer and use it in GitHub Desktop.
function greaterThan(n) {
return function(m) {
return m > n;
};
}
var greaterThanTen = greaterThan(10);
var result1 = greaterThanTen(11)
console.log(result1)
var result2 = greaterThanTen(9)
console.log(result2)
@suhailgupta03
Copy link
Author

A Higher-Order Function (HOF) in JavaScript is a function that does at least one of the following:

  1. Takes one or more functions as arguments.
  2. Returns a function as its result.

So, while it's common for higher-order functions to accept other functions as arguments, it's not a requirement. A function can be considered a higher-order function if it returns a function, even if it doesn't accept any function as an argument.

@suhailgupta03
Copy link
Author

@suhailgupta03
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment