First-Class Citizen (Computer Science)
In programming, an entity is called First-Class Citizen if all of the following apply:
- it can be passed as an argument to another function
- it can be returned as a value
- it can be assigned as a value
JavaScript Example
In JavaScript, functions are treated as First-Class Citizens:
const f = x => x + 1;
const g = f => f;
// 1. argument: g(f)
// 2. return value: return f
// 3. assignment: h = g(f)
const h = g(f);
h(1); // 2
g()
serves as a Higher-Order Function as it takes a function as an
argument.
see also