Javascript 将一个变量赋给一个非常大的数组会使其未定义
我使用了一些端点来获取所有加密硬币的简单信息,这个列表非常大 2个清晰的例子来说明问题Javascript 将一个变量赋给一个非常大的数组会使其未定义,javascript,json,bigdata,Javascript,Json,Bigdata,我使用了一些端点来获取所有加密硬币的简单信息,这个列表非常大 2个清晰的例子来说明问题 // example one var arrWithSmallLength = [ { name: 'Bitcoin', symbol: 'btc', id: 'bitcoin', image: 'bitcoin_logo_url' },.....]; // length of arrWithSmallLength is less than 1000 console
// example one
var arrWithSmallLength = [ {
name: 'Bitcoin',
symbol: 'btc',
id: 'bitcoin',
image: 'bitcoin_logo_url'
},.....];
// length of arrWithSmallLength is less than 1000
console.log(arrWithSmallLength); // it prints the array normally
// example two
var arrWithBigLength = [ {
name: 'Bitcoin',
symbol: 'btc',
id: 'bitcoin',
image: 'bitcoin_logo_url'
},.....];
// length of arrWithBigLength is more than than 8000
console.log(arrWithBigLength); // it prints undefined
在VS代码中呈现的arrWithBigLength超过78500行
更新
在此链接中找到数据有效负载:在json文件中,查找值“Staked yAxis”。在此条目之后,您将找到
}
]
[
{
这里再次重复数据,导致json定义错误。删除这一行之后的双精度键,数据就会正常工作。第39273行之后的所有内容都不应该出现,除了结尾}。您能显示加载数组的代码吗?没有代码加载它,只需将其分配给变量并尝试记录它。当我说加载时,我的意思是为该数组分配8000多个元素。你是怎么做到的?用for循环?通过手动设置length=8000?不,这是一个现成的数据硬编码,因为您的示例不包含导致问题的实际数据,所以我尝试了以下方法:var arrhithbigtlength=Array.from{length:20000}.mapx,I=>{name:'Bitcoin-'+I,symbol:'btc-'+I,id:'Bitcoin-'+I,image:'Bitcoin\u logo\u url'+1};console.logarrWithBigLength;。这对20000张唱片来说非常有效。未定义意味着加载到变量中的实际固定数据有问题。