Ordered hash in JavaScript

前端 未结 9 1017
心在旅途
心在旅途 2020-12-05 17:34

JavaScript objects have no order stored for properties (according to the spec). Firefox seems to preserve the order of definition of properties when using a for...in<

9条回答
  •  不知归路
    2020-12-05 17:56

    No, since the Object type is specified to be an unordered collection of properties, you can not rely on that. (Or: You can only rely on that an object is an unordered collection of properties.)

    If you want to have an ordered hash set, you will need to implement it on your own.

提交回复
热议问题