The typeof operator in JavaScript returns “function” for functions.
However, JavaScript functions are essentially objects.
Functions in JavaScript have both properties and methods.
The arguments.length property returns the number of arguments passed when the function is invoked.
function myFunction(a, b) { return arguments.length; } |
The toString() method returns the function as a string representation.
function myFunction(a, b) { return a * b; } let text = myFunction.toString(); |
A function defined as a property of an object is called a method of that object. A function designed to create new objects is called an object constructor. |