Problems with Javascript and Firefox 4

The code below works fine in FF3.X and IE7 to 9, but not in FF4.

I have this code in 2 places in my file:

                var arguments = "method=getoptions";
                arguments += "&dropzone=" + dictKey;
                arguments += "&format=disc";
                arguments += "&datasetid=" + datasetid;
                arguments += "&varnumber=" + varnumber;
                arguments += "&varSectionId=" + varSectionId;
                arguments += "&catindex=" + catIndex;
                arguments += "&defaultid=dv_cat_opts_default_body";
                arguments += "&mmocid=dv_cat_opts_mmoc_body";

                 alert(arguments);

which produces

               method=getoptions&dropzone=Row_1&format=disc&datasetid=1&varnumber=206&varSectionId=FUV&catindex=&defaultid=dv_cat_opts_default_body&mmocid=dv_cat_opts_mmoc_body

and this is true, but the same code is elsewhere in the file

                 var arguments = "method=getoptions";
                arguments += "&dropzone=" + dictKey;
                arguments += "&format=disc";
                arguments += "&datasetid=" + datasetid;
                arguments += "&varnumber=" + varnumber;
                arguments += "&varSectionId=" + varSectionId;
                arguments += "&catindex=" + catIndex;
                arguments += "&defaultid=dv_cat_opts_default_body";
                arguments += "&mmocid=dv_cat_opts_mmoc_body";

                 alert(arguments);

outputs this that ends up with an error call in my ajax:

             [object Arguments]&dropzone=Row_1&format=cont&datasetid=1&varnumber=1125&varSectionId=FUV&catindex=&defaultid=dv_cont_opts_default_body&mmocid=dv_cont_opts_mmoc_body

So what is the deal with this object arguments?

+3
source share
2 answers

A variable argumentsis a special object accessible within functions; it contains all the arguments passed to the function.

https://developer.mozilla.org/en/JavaScript/Reference/functions_and_function_scope/arguments

, arguments - , if, arguments, .

, - ​​ , . , , . , . Mootools jQuery, , arguments.

:

function alertError() {
 var exception = false;
 var message = false;
 for( var i = 0; i < arguments.length; i++ ) {
  if (typeof arguments[i] == 'object')
    exception = arguments[i];
  if (typeof arguments[i] == 'string')
    message = arguments[i];
 }

 if (message == false)
   message = 'No details';
 if (exception != false)
   message += ', exception: '+exception.message;

 alert('There has been an error: '+message);
}
alertError("No exceptions here!");
try {
 var t = t.doesnotexist;
} catch (e) {
 alertError(e, 'Testing');
}

: http://jsfiddle.net/zwGMJ/

+4

arguments - JavaScript, ( ) . , , function(a){alert(a);} , function(){alert(arguments[0]);}. , .

Ad @

+1

All Articles