@fma:

> Is it possible to pass again this var to another function? What if I
> do:

Worth reading up on the `arguments` variable in the spec[1] (warning,
multi-meg PDF). Also check out Function#apply, which is probably what
you're looking for:

var Thingy = Class.create((function(){
    function foo() {
        bar.apply(this, arguments);
    }
    function bar(a, b, c) {
        alert("a = " + a);
        alert("b = " + b);
        alert("c = " + c);
    }

    return {foo: foo, bar: bar};
})());

var t = new Thingy();
t.foo(1, 2, 3);
// Alerts "a = 1", then "b = 2", then "c = 3"

The first argument to Function#apply is the context (the value `this`
should have within the call). The second argument is an array (or
array-like thing, such as `arguments`) of arguments to pass to the
function.

[1] 
http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf

@Alex:

> arguments is global...

No, it's local to the function scope, like the formal arguments and
vars inside the function (in fact, like them it's a property of the
variable object for that execution context).
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

On Dec 7, 12:26 pm, "Alex McAuley" <[email protected]>
wrote:
> arguments is global...
>
> consider this ...
>
> function foo('one','two','three')  {
> alert(arguments[0]); // one
> alert(arguments[1]); // two
> alert(arguments[2]); // three
>
> }
>
> Alex Mcauleyhttp://www.thevacancymarket.com
>
>
>
> ----- Original Message -----
> From: "fma" <[email protected]>
> To: "Prototype & script.aculo.us" <[email protected]>
> Sent: Monday, December 07, 2009 11:53 AM
> Subject: [Proto-Scripty] Re: Custom signal
>
> > Good!
>
> > Is it possible to pass again this var to another function? What if I
> > do:
>
> > function func2(arguments) {
> > ...
> > }
>
> > function func1() {
> >    func2(arguments);
> > }
>
> > func1(a, b);
>
> > Does it work?
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Prototype & script.aculo.us" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/prototype-scriptaculous?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.


Reply via email to