In a functional programming language, functions are first class citizens.

They can be assigned to variables

const f = (m) => console.log(m)
f('Test')

Since a function is assignable to a variable, they can be added to objects:

const obj = {
  f(m) {
    console.log(m)
  }
}
obj.f('Test')

as well as to arrays:

const a = [
  m => console.log(m)
]
a[0]('Test')

They can be used as an argument to other functions

const f = (m) => () => console.log(m)
const f2 = (f3) => f3()
f2(f('Test'))

They can be returned by functions

const createF = () => {
  return (m) => console.log(m)
}
const f = createF()
f('Test')

Go to the next lesson