Table of Contents

About

This page is about function arguments in javascript.

Snippet

the built-in arguments variable

The 'arguments' object cannot be referenced in an arrow function in ES3 and ES5.

let fn = function() {
   console.log(arguments)
   console.log("First Argument: "+arguments[0]);
   console.log("All Arguments joined: "+Object.values(arguments).join(", "));
   console.log("The type is "+(typeof arguments))
   console.log("The class is "+arguments.constructor.name)
};

fn('arg1','arg2');

default

let fn = function(name="Foo") {console.log(`Hello ${name}`)};

fn();

Rest

It's also working with Rest argument

let fn = function(name="Foo",...rest) {console.log(`Hello ${name} and the rest ${rest}`)};

fn("Bar","Foo","Foobar");

Documentation / Reference