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

Milian Wolff mail at milianw.de
Thu Aug 8 08:46:21 CEST 2013


On Wednesday 07 August 2013 19:21:50 Knoll Lars wrote:
> 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.

Ah yes, my bad - thanks for the clarification. Here's where my confusion comes 
from:

function foo() { console.log(arguments); }

foo(1,2,3,4);

QML: [object Arguments]
Chromium: [1,2,3,4]

So I added JSON.stringify to QML and assumed one is an array whereas one is an 
object. Odd that Chromium at least special-cases the output of 
console.log(arguments).

Cheers
-- 
Milian Wolff
mail at milianw.de
http://milianw.de



More information about the Development mailing list