数组显示为空,但它包含值 [英] Array is showing up as empty, yet it contains values

查看:643
本文介绍了数组显示为空,但它包含值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


任何人都可以帮助我理解为什么数组显示为空,当它还显示它有数据/值时?

Can anyone help me understand why the Array is showing as being empty, when it also shows that it has data/ values ?

我无法访问数据。见图片以供参考。

I am not able to access the data. See picture for reference.

推荐答案

在Javascript控制台中记录的对象是实时,因此展开它们会显示对象的当前内容。第一行显示当您第一次调用 console.log()时, outputList 为空。但是稍后会在数组中添加一些内容,当您通过单击显示三角形展开对象时,您会看到更新的值。

Objects logged in the Javascript console are "live", so expanding them shows the current contents of the object. The first line shows that the outputList was empty when you first called console.log(). But something was added to the array later, and when you expanded the object by clicking on the disclosure triangle, you see the updated value.

这篇关于数组显示为空,但它包含值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆