Thursday, October 5, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  78] [ 2]  / answers: 1 / hits: 73429  / 15 Years ago, wed, april 1, 2009, 12:00:00

In a recent question, I received suggestions to talk on, amongst other things, the aspect of JavaScript where functions are 'first class' objects. What does the 'first class' mean in this context, as opposed to other objects?

EDIT (Jörg W Mittag): Exact Duplicate: What is a first class programming construct?

More From » javascript


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

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...

[#99769] Wednesday, March 25, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 552
Total Questions: 87
Total Answers: 104

Location: Burundi
Member since Sat, Aug 21, 2021
2 Years ago
byronkodyo questions
Wed, Jul 6, 22, 00:00, 1 Year ago
Wed, Mar 17, 21, 00:00, 3 Years ago
Mon, Sep 14, 20, 00:00, 3 Years ago
Thu, May 21, 20, 00:00, 3 Years ago