I just discovered chromestatus.com and, after losing several hours of my day, found this feature entry :
(我刚发现chromestatus.com,在失去了一天的时间后,发现了以下功能条目 :)
Map: Map objects are simple key/value maps.
(映射:映射对象是简单的键/值映射。)
That confused me.
(那让我感到困惑。)
Regular JavaScript objects are dictionaries, so how is a Map
different from a dictionary?(常规JavaScript对象是字典,那么Map
与字典有何不同?)
Conceptually, they're identical (according to What is the difference between a Map and a Dictionary? )(从概念上讲,它们是相同的(根据Map和Dictionary之间的区别是什么? ))
The documentation chromestatus references doesn't help either:
(chromestatus文档参考无济于事:)
Map objects are collections of key/value pairs where both the keys and values may be arbitrary ECMAScript language values.
(映射对象是键/值对的集合,其中键和值都可以是任意ECMAScript语言值。)
A distinct key value may only occur in one key/value pair within the Map's collection.(一个唯一的键值只能出现在地图集合中的一个键/值对中。)
Distinct key values as discriminated using the a comparision algorithm that is selected when the Map is created.(使用创建地图时选择的比较算法来区分的不同键值。)
A Map object can iterate its elements in insertion order.
(Map对象可以按插入顺序迭代其元素。)
Map object must be implemented using either hash tables or other mechanisms that, on average, provide access times that are sublinear on the number of elements in the collection.(必须使用哈希表或其他机制来实现Map对象,这些机制通常提供的访问时间与集合中元素的数量成线性关系。)
The data structures used in this Map objects specification is only intended to describe the required observable semantics of Map objects.(本Map对象规范中使用的数据结构仅用于描述Map对象所需的可观察语义。)
It is not intended to be a viable implementation model.(它并非旨在成为可行的实施模型。)
…still sounds like an object to me, so clearly I've missed something.
(…对我来说听起来还是一个对象,所以很明显我错过了一些东西。)
Why is JavaScript gaining a (well-supported) Map
object?
(为什么JavaScript会获得一个(得到良好支持的) Map
对象?)
What does it do?(它有什么作用?)
ask by Dave translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…