Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

2 of 2
added 480 characters in body
Pointy
  • 415.2k
  • 62
  • 600
  • 633

Because you're only passing one argument — the array.

Try alert(foo(1,2,3,4,5));

Arguments are numbered from 0 in JavaScript, so when you start your slice at 1 and pass 1 argument, you get nothing.

Note that it can hamper optimization to allow the arguments object to "leak" out of a function. Because of the aliasing between arguments and the formal parameters, an optimizer can't really do any static analysis of the function if the arguments object gets sent somewhere else, because it has no idea what might happen to the parameter variables.

Pointy
  • 415.2k
  • 62
  • 600
  • 633

AltStyle によって変換されたページ (->オリジナル) /