To quote Wikipedia:
In computer science, a programming
language is said to support
first-class functions (or function
literal) if it treats functions as
first-class objects. Specifically,
this means that the language supports
constructing new functions during the
execution of a program, storing them
in data structures, passing them as
arguments to other functions, and
returning them as the values of other
functions.
This page also illustrates it beautifully:
Really, just like any other variable
- A function is an instance of the Object type
- A function can have properties and has a link back to its constructor method
- You can store the function in a variable
- You can pass the function as a parameter to another function
- You can return the function from a function
also read TrayMan's comment, interesting...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…