How to Use Function "Constructors"

Functions can be created using a "function" statement or the Function() constructor. Dynamic functions are created when defining functions with the "new" operator and Function() constructor. Constructors not only create new objects but also specify the behaviors and properties of those objects.

Instance properties

These properties are defined on Function.prototype and shared by all Function instances.

Function.prototype.arguments Deprecated Non-standard

Represents the arguments passed to this function. For strict, arrow, async, and generator functions, accessing the arguments property throws a TypeError. Use the arguments object inside function closures instead.

Function.prototype.caller Deprecated Non-standard

Represents the function that invoked this function. For strict, arrow, async, and generator functions, accessing the caller property throws a TypeError.

Function.prototype.constructor

The constructor function that created the instance object. For Function instances, the initial value is the Function constructor.

These properties are own properties of each Function instance.

displayName Non-standard Optional

The display name of the function.

length

Specifies the number of arguments expected by the function.

name

The name of the function.

prototype

Used when the function is used as a constructor with the new operator. It will become the new object's prototype.