read the name of the optional arguments of a function
<p>I have a bunch of functions (methods of a class actually) and I'm writing a method that will record the interactions with other methods in an array.
so for example :</p>

<pre><code> foo = Base.extend ({
      a : function (a1,a2){
            ....
      },
      b:function(b1,b2){
        ...
      },
      history : function(){ ... }
  })
</code></pre>

<p>to simplify the history method, I'd like to read the name of the optional arguments and add them to the array, so for example if the method a is called, I want to record a1,a2 ...
so basically, is there any way to read the name of the optional arguments list of an array in javascript ?</p>

<p>here is the code :</p>

<pre><code>var element = Base.extend({
constructor : function() {
    if(arguments.length==1){
        ...
    }else{
        ...
    }
},
setLocation : function (top, left){
    oldArgs = [this.top,this.left];
    this.top = top;
    this.left = left;
    return(oldArgs);
},
setAspects : function (width, height){
    oldArgs = [this.width,this.height]
    this.width = width;
    this.height = height;
    return(oldArgs);
},
draw : function (page){
    ...
},
delet : function () {
        ...
},
$ : function(method,args){
    var oldArgs = this[method].apply(this,args);
    this.history(method,oldArgs);
    Nx.pages[this.page].modified = true;
},
history : function (method,args){
    Nx.history[Nx.history.length]=[this.id,method,args]
}
</code></pre>

<p>})</p>

<p>so in this class, if I want to call any method, I'll pas it through the $ method, and it will call the history method, so far what I've done is for example in the setLocation method it will return the old arguments and I will story them in my array Nx.history, but it's easier to factorise all of these "return" calls in the methods, and add a line to the $ method , that reads the name of the expected arguments of the method, and send it to the history method, so something like this :</p>

<pre><code>$ : function(method,args){
    this[method].apply(this,args);
    **var oldArgs = this[method].arguments // get the list of argument names here
    $.each(oldArgs, function(value) { Args[Args.length] = this.value //get the stored value in the class
    })
    this.history(method,Args); // and pass it to the history**
    Nx.pages[this.page].modified = true;
}
</code></pre>
