[bug?] arguments.pop() arguments.push() not a function

    Dec 24 2009 | 3:18 pm
    When I tried calling pop() and push() on the arguments Array inside an anything() function, Max tells me they are not functions. pop() and push() seem to work as expected in other Arrays. I noticed this problem on Max 5.0.7 and 5.1 on OS X 10.5.8. Here is a bit of JS and a patch demonstrating:
    autowatch = 1;
    function anything() {
        var a = new Array("a", "b", "c");
        for (var i in a)
        //post last element in array
        //pop off last element
        //print elements in array
        for (var i in arguments)
    I've thought about this a little more. Is arguments some sort of strange immutable array that allows you to change values, but not size?

    • Dec 24 2009 | 5:58 pm
      The arguments property is not an array, it just seems a bit like one, its a bit confusing I know. You need to do something like:
      var theInput = arrayfromargs(messagename,arguments);
      and then you can use array methods like pop() and push() on theInput.
    • Dec 27 2009 | 3:54 pm
      Interesting, figured it was something like that. Just curious: so what exactly is it. Is this a JavaScript or max feature? Never noticed it in the JavaScript reference.
    • Dec 27 2009 | 4:40 pm
      It is a feature of javascript itself, have a read here for a bit more information.
    • Jan 17 2010 | 1:14 am
      First, the code sample is a little wonky - it's justvar theInput = arrayfromargs(arguments) (unless there's something I don't know about arrayfromargs??)
      Second, the arguments array is like a stripped down Array that only has indexing and length - the reason is to get rid of the overheard required in creating a new Array every time you make a function call.
      It's a necessary workaround for Javascript's lame argument passing (look at Python, much better) but we don't have to love it...
    • Jan 17 2010 | 2:15 am
      Ah yes, to avoid confusion I should explain more clearly. The messagename can be used to dynamically process input received using the anything() function. You don't need to use it if you just want the arguments and you have a specific function already declared.
      The first example below will output whatever you send to the input. The second example will output the arguments of a "somename" message but not the string "somename" itself.
      function anything() {
      function somename() {