JavaScript: Function Object

By Xah Lee. Date: . Last updated: .

Function is the value of the property key "Function" of the Global Object .

console.log( window.Function === Function ); // true

Type

Type of Function is a function.

console.log( typeof Function === "function" ); // true

Parent

Parent of Function is Function.prototype. [see Prototype and Inheritance]

console.log( Reflect.getPrototypeOf ( Function ) === Function.prototype ); // true

Purpose

Purpose of Function is:

Function Constructor

Function Constructor

Properties

// every function has a own property β€œlength”

console.log( ((x) => x+1).hasOwnProperty ("length") );
console.log( Function.hasOwnProperty ("length") );
console.log( Function.prototype.hasOwnProperty ("length") );

// Its value is number of parameters in the argument, not counting Argument Default Value and Rest Parameters
console.log( (() => []).length === 0);
console.log( ((x) => [x]).length === 1);
console.log( ((x,y) => [x,y]).length === 2);
console.log( ((x,y=4) => [x,y]).length === 1);
console.log( ((x,...y) => [x,y]).length === 1);

// all true

JavaScript Function

βˆ‘ JS in Depth
XAH Β BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Function

prototype