开发者

javascript too many constructor arguments

I'm trying to import a set of coordinates from an external javascript. I have to include about 78.740 elements in the constructor, but fir开发者_StackOverflow中文版efox just throws an error:

"too many constructor arguments"

Does anybody have any ideas?

This is my code:

function CreateArray() {   
return new Array(
...
...
...
78.740 elements later
...
); }


Try array literal, it worked for me (tested with success for million items):

function CreateArray() {   
    return [
        ...
    ];
}


You may be running into memory limitations, not sure.

How about trying to push() the values into an array instead of initializing all of them all at once? Break it into smaller chunks of data to add to the array instead of adding it all in one command.

var a = [];
a.push(1,2,3,4,5,6,7,8,9,10);
a.push(1,2,3,4,5,6,7,8,9,10);
a.push(1,2,3,4,5,6,7,8,9,10);
a.push(1,2,3,4,5,6,7,8,9,10);
// etc...
return a;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜