Categories

Oct 19, 2019 in JavaScript

Q: How can you get the total number of arguments passed to a function?

1 Answer

Oct 19, 2019
Using arguments.length property, we can get the total number of arguments passed to a function. For example −

function func(x){

   console.log(typeof x, arguments.length);

}

func();                //==> "undefined", 0

func(1);               //==> "number", 1

func("1", "2", "3");   //==> "string", 3
Click here to read more about JavaScript
Click here to read more about Insurance

Related questions

Madanswer
May 27, 2019 in Data Handling
Oct 19, 2019 in JavaScript
Dec 22, 2019 in Python
...