开发者

javascript too many constructor arguments

开发者 https://www.devze.com 2023-01-15 15:22 出处:网络
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:

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

精彩评论

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

关注公众号