订单的产品在ActionScript对象订单、对象、产品、ActionScript

2023-09-08 14:44:26 作者:我要破茧而出

尝试编译:

var object:Object = {};

object.one = "foo";
object.two = "foo";
object.three = "foo";
object.four = "foo";

for(var key:String in object)
{
    trace(key);
}

...您将获得:

... you will get:

one
four
two
three

为什么搞砸了订单?

Why the messed up order?

推荐答案

对象的键没有顺序。如果您需要preserve秩序,有查找,那么你需要创建一个自定义集合,提供了该功能。

The keys of an object are not ordered. If you need to preserve order and have a lookup, then you need to create a custom collection that provides that functionality.

 
精彩推荐