Animations

API

Arrays

Async

Basics

Challenges

Classes

Console

Dates

Debugging

DOM Elements

DOM Methods

DOM Navigation

DOM Properties

Event Listeners

Flow Control

Forms

Functions

Global Functions

JSON

Keywords

Libraries (3rd party)

Math

Modules

Objects

Snippets

String

Types

Widgets

Window Object

JavaScript - Functions Are Objects

arguments.length
Since functions have both properties and methods, they are considered objects. The arguments.length property returns the number of arguments received when the function was invoked.


function myFunction(a, b)
{
    return arguments.length;
}
document.getElementById("demo1").innerHTML = myFunction("foo", "bar");

 

toString()
The toString() method returns the definition of the function. Note that we do not pass the actual arguments.


function myFunction(a, b)
{
    return arguments.length;
}
document.getElementById("demo1").innerHTML = myFunction.toString();