derek5. 2018-02-28 20:12 采纳率: 100%
浏览 12

仅具有1个键的改革数组[重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/34070739/how-to-stop-google-chrome-from-restructuring-long-arrays" dir="ltr">How to stop Google Chrome from restructuring long arrays?</a>
                            <span class="question-originals-answer-count">
                                (4 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2018-02-28 20:18:46Z" class="relativetime">2 years ago</span>.</div>
        </div>
    </aside>

Working with some data from a JSON/Array from a known video game. I'm close to creating a new array with ONLY the localized name, but can't quite get it right. What am I missing:

const endpoint = './heroes-org.json'
let heroes = []
let renamed = []

fetch(endpoint)
  .then(text => text.json())
  .then(data => heroes.push(...data.result.heroes))
  .then(() => {
    for(i = 0; i < heroes.length; i++){
        // renamed += heroes[i].localized_name
        //heroes.map(function){
        //}
        setTimeout(function(){
            console.log(renamed)
        }, 2000)
    }})

The map function was an idea to get rid of the unnecessary keys of each array element.

Also, if I just console log heroes from within the chrome console shows me this:

enter image description here

Doesn't seem quite right. Why is my array separated into 0-99 etc.?

I ultimately want to end up with just 1 array containing all the 115 heroes' names.

</div>
  • 写回答

1条回答 默认 最新

  • weixin_33735077 2018-02-28 20:17
    关注

    It is just a feature of Chrome. Chrome breaks up an array into smaller parts consisting of 100 elements for easier debugging. Look at length property, it's value is 115 :)

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看