for(var i in obj)问题 [英] for (var i in obj) question
本文介绍了for(var i in obj)问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个对象数组。
我在表格中显示数组的内容。
然后我有一个链接它允许用户对表进行排序。我这样做是通过排序数组,删除表的内容,然后重新显示数组的内容。但是for(var i in obj)似乎使用原始订单。我可以在firebug中看到数组已正确排序。那么为什么它保持原始的排序顺序呢?
这是我的示例代码,下面是排序后数组的屏幕截图;
I have an array of objects.
I display the content of the array in a table.
Then I have a link which lets the user sort the table. I do that by sorting the array, delete the content of the table and then redisplay the content of the array. But the "for (var i in obj)" seems to use the original order. I can see in firebug that the array is properly sorted. So why does it maintain the original sort order?
Here is my sample code and below is a screen shot of the array after sorting;
展开 | 选择 | Wrap | >行号
推荐答案
在尝试自己时,排序发生。
upon trying myself, sorting occured.
我刚刚添加了一张图片从萤火虫看到的阵列。对数组进行排序,但是for(var i in obj)正在使用原始排序顺序。为什么会这样?
I just added a picture of the array as viewed from firebug. The array is sorted but the "for ( var i in obj)" is using the original sort order. Why would this be?
从图片判断, a7DayKeys 不是标准数组(除了Firebug总是显示属性和方法排序)
出于兴趣,
judging from the picture, a7DayKeys is not a standard array (besides that Firebug always display the properties and methods sorted)
out of interest, what does
展开 | 选择 | Wrap | 行号
这篇关于for(var i in obj)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文