-1

Can someone explain this term for me and describe a typical programming situation where first-class functions are used? Thanks

  • 1
    Welcome to [so]. Could you explain what you don't understand when you searched up "first-class functions"? Also what do you need to do this for? – Qantas 94 Heavy Jun 10 '15 at 08:53

1 Answers1

2

We often hear that JavaScript functions are first-class functions, meaning both functions and objects are treated by the language as the same thing. In practical terms, a function can be stored as a variable, inside an array or an object, as well as it can be passed as an argument or be returned by another function. That makes functions “first-class citizens” in JavaScript.

These are the examples:

var myfunc2 = function(a)
{
 return a + 1;
};

var myfunc2 = function myfunc4(a)
{
 return a + 1;
};

Refer the following links

http://odiseo.net/javascript/first-class-functions-in-javascript-how-comes-functions-are-treated-as-objects-in-js

http://www.developerfusion.com/article/84433/first-class-functions/

Libin C Jacob
  • 1,108
  • 12
  • 34