In brief: allow Symbol's to be constructed with a single parameter, with
the following behavior:
> var obj = {};
undefined
> new Symbol({}) === new Symbol({})
false
> new Symbol(obj) === new Symbol(obj)
true
Motivation: the ability to construct equal Symbols gives us the necessary
building blocks to build custom maps with semantics very similar to Simple
Maps[1]:
function ObjectMap() {
this.map = {};
}
SimpleMap.prototype.set = function(objKey, val) {
this.map[new Symbol(objKey)] = val;
};
SimpleMap.prototype.get = function(objKey) {
return this.map[new Symbol(objKey)];
};
At a surface level, this seems more novelty than anything else, but I think
it's a useful primitive for building more complex and robust features on
top of Symbols. Thoughts?
[1] http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets
--
Jeremy Martin
661.312.3853
http://devsmash.com
@jmar777
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss