Garrett Smith dhtmlkitchen at
Thu Sep 11 09:47:30 PDT 2008

On Wed, Sep 10, 2008 at 6:33 PM, David-Sarah Hopwood
<david.hopwood at> wrote:
> Garrett Smith wrote:
>> On Wed, Sep 10, 2008 at 3:41 PM, David-Sarah Hopwood
>> <david.hopwood at> wrote:
>>> Mark S. Miller wrote:
>>>> On Tue, Sep 9, 2008 at 9:51 PM, Brendan Eich <brendan at> wrote:

>> Why would "Function.apply3" need three arguments?
> Because Function.prototype.apply takes two arguments, and apply3
> (or staticApply, or whatever it is called) makes the 'this' argument
> explicit.
>> Function.prototype.apply doesn't actually need any arguments.
> No, it always takes two arguments, which may be undefined. But since
> an undefined argument can't be distinguished from a missing one, that
> does mean it's not possible to condition on whether there are two or
> three arguments. (Besides, I withdrew the suggested name 'apply3'.)

No, it doesn't always take two arguments. It takes whatever arguments
I pass it. I just called it with 0 arguments and it took that.

A missing argument could absolutely be distinguished from an argument.

function countArgs(a, b) {
  if(a === undefined && b === undefined) {

When a countArgs is enterered, the Variable object gets the properties
|a| and |b|. If the caller supplied fewer arguments than the number or
formal parameters, the extra formal parameters have value |undefined|

The |arguments| object is initialized with a |length| property that
holds the number of actual parameter values supplied by the caller.


countArgs(undefined, undefined);

elerts "2"

>> See for yourself:-


> --
> David-Sarah Hopwood

More information about the Es-discuss mailing list