Map
usually uses .get()
/.set()
/.delete()
/.has()
, but it'd be nice if Map
pairs were accessed as regular ECMAScript properties, noting the following:
- When reading/writting a property on
Map
, it is a pair access. - When calling a property on
Map
with aString
key, it is a call of aMap.prototype
method. - For
Function
pairs to be called, you have to do[object Map].call("f", ...rest)
.
This would require .size
to be .size()
or .length()
(similiar to the legacy E4X feature).
This idea is borrowed from the E4X XML
/XMLList
proposal. Originally I think ECMAScript 4 was also going to support Map.<K, V>
with similiar semantics.
And now it's too late for this change. The only hope is if there is a directive like "use strict";
to change it, but it's complicated...