Created
August 9, 2023 16:35
-
-
Save suhailgupta03/01a9936015789cb11283c354e59ec2ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A Higher-Order Function (HOF) in JavaScript is a function that does at least one of the following:
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.