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