[Development] Why is "arguments" in a QML/JS function a map and not an array?

Knoll Lars Lars.Knoll at digia.com
Wed Aug 7 21:21:50 CEST 2013

Actually it's not. I just checked the specs (see
http://ecma-international.org/ecma-262/5.1/#sec-10.6), and the arguments
object is a JS object not a JS array.

This JS snippet

function foo() {    print(JSON.stringify(arguments))}
foo(1, 2, 3, 4)

gives exactly the same answer as below in any JS engine.


On 8/7/13 9:18 PM, "Knoll Lars" <Lars.Knoll at digia.com> wrote:

>Looks like a bug. Could you please create a Jira task for it?
>On 8/7/13 5:20 PM, "Milian Wolff" <mail at milianw.de> wrote:
>>Hey there!
>>I noticed that the magic "arguments" is a map and not an array in QML/JS
>>functions. Is this intended? If so, why? If not, can it be changed or
>>that break some code?
>>Item {
>>  function foo() {
>>    console.log(JSON.stringify(arguments));
>>  }
>>  Component.onCompleted: {
>>    foo(1, 2, 3, 4);
>>  }
>>actual output:
>>expected output (which is also what "proper" javascript in a browser
>>[1, 2, 3, 4]
>>Milian Wolff
>>mail at milianw.de
>>Development mailing list
>>Development at qt-project.org
>Development mailing list
>Development at qt-project.org

More information about the Development mailing list