Wednesday, March 7, 2012

First-class function

In programming languages, first-class object means
  1. can be stored in variables and data structures
  2. can be passed as a parameter to a subroutine
  3. can be returned as the result of a subroutine
  4. can be constructed at run-time
  5. has intrinsic identity (independent of any given name)
In Javascript, first-class function (which is also an object) has below characteristics
  1. passing functions as arguments
  2. returning functions as results
  3. assigning functions to variables     
  4. storing them inside (global) data structures

1 comment:

  1. function.prototype: Despite the fact changing a prototype affects all of the instances, replacing a constructor’s prototype entirely does not affect older instances.

    ReplyDelete