On Mon, Jan 16, 2012 at 2:11 PM, David Bruant <[email protected]> wrote:
[...]
> > What additional value does this contingent mutation add, regardless of
> > how it's packaged?
> What additional value adds the default value when something very close
> is achieved with "wm.get(o) || defaultValue"?
> Do you have use cases of storing falsy values in WeakMaps? If so, then
> the difference matters.
That's precisely what I'm confused about. I agree that "||" doesn't work
when the map is used to store falsy values. But the FF get/2 works
perfectly fine:
> !!0;
false
> !!'';
false
> var wm = WeakMap();
> var x = {};
> var y = {};
> wm.set(x, 0)
> wm.get(x, '')
0
> wm.get(y, '') === '';
true
> wm.has(x)
true
> wm.has(y)
false
That seems ideal.
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss