Crockford on Javascript - if too many arguments they're ignored(?)

Hey,

I’m watching Crockford’s series on Javascript.

In act III in this moment:https://youtu.be/ya4UHuXNygM?list=PL7664379246A246CB&t=804

he says “If too arguments are being passed to a function - they’re ignored. But they still go to arguments array”.

I know about arguments array-like object. But i don’t get how are the extra arguments really “ignored” if they’re passed to the function in arguments object? I mean, i have access to those extra ones, so where is the “ignoring”?

For example having a function:

function add (x, y, z) {
var sum = 0;
 for (var i =0; i < arguments.length; i++) { 
 sum += arguments[i];
 }
}

add(1,2,3,8,9);

I’m still adding all 5 numbers, right?

You are right, they aren’t ignored.

1 Like

He means they are ignored in the sense that x is set to 1, y is set to 2, and z is set to 3, while nothing is set to 8 and 9 (and so are ignored in terms of the function parameters).

3 Likes