Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when I give more parameters than required in the function in Javascript?

Tags:

javascript

Assume -

function noname(a, b) {
//code
}

and I give -

noname(4,5,6,7);

What will happen then?

like image 305
Namanyay Goel Avatar asked Nov 04 '25 17:11

Namanyay Goel


1 Answers

The additional parameters will simply get ignored.

They will however be available as part of the arguments pseudo-array, e.g. as arguments[2], arguments[3].

If you give fewer variables than are required then the missing ones will be undefined.

like image 70
Alnitak Avatar answered Nov 07 '25 09:11

Alnitak