Difference between high-order and first-class functions

Asked

Viewed 5,340 times

15

In functional language, what is the difference between high-order functions (high-order functions) and first-class functions (first-class functins)?

In Javascript, what would be the difference between these two types of functions?

1 answer

19


A language has first class functions, when functions can be treated as values that can be passed, manipulated, returned... that is, it is possible to operate functions. This concept is an attribute of language, either she has or she doesn’t have.

High-order function is a function that receives or returns a function. It is only possible to define a high-order function if the language has first class functions, as functions need to be "passable". This concept is an attribute of the function, whether or not it is.

EDIT

Languages that do not have first-class functions, such as C, yet enable the creation of high-order functions, using function pointers.

Javascript is a language that has first-class functions, i.e., it is possible to pass, return and operate functions.

Reference:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.