This project has moved. For the latest updates, please go here.
1

Closed

ArrayInstance.Construct() implementation

description

Hello,

If I call ArrayInstance.Construct with an single (number) argument I get back an array with the length 1, but no elements filled in. But actually I wanted to create an array with exactly this element.

The issue comes from jurassic only having a single overload which uses a params parameter, so it cannot tell the difference between passing in an array or passing in a single int.

In a browser (testable with the firefox debugging tools) it makes a difference wether I call new Array(1) or new Array([1]). First one is the behaviour jurassic provides, second is the one which I cannot achieve with the Construct method.

Workaround is to use New() rather than Construct() but this still is very confusing (and time consuming to find).

Regards,
Ablu
Closed Sep 9, 2015 at 12:58 AM by paulbartrum
Not a bug.

comments

paulbartrum wrote Sep 8, 2015 at 12:00 AM

If I do new Array([1]) in the browser, I get a new array containing another array. I'm pretty sure this is not what you want either.

ArrayConstructor.Construct is equivalent to new Array() so it must have the same behavior, even if that behavior is confusing :-)

ablu wrote Sep 8, 2015 at 7:06 AM

If I do new Array([1]) in the browser, I get a new array containing another array. I'm pretty sure this is not what you want either.
Aaah... Sorry I did not realized this. I thought it was a single array...

Ok then everything is ok :)

Sorry for the noise!

Regards,
Ablu