Thoughts on WeakMaps

Isaac Schlueter i at izs.me
Tue Jun 7 14:58:00 PDT 2011


On Tue, Jun 7, 2011 at 13:59, Mark S. Miller <erights at google.com> wrote:
> There's no where in the standard API of the ES5 built-ins that does this
> return-self pattern for purposes of chaining. There are of course JS
> libraries, like jQuery, that make pervasive use of chaining. However,
> ES-next built-ins should first respect the precedent of the general style of
> other built-ins, in order to be least surprising.

+1

IMO, the "return the set value" approach seems to make the most sense,
since map.set(k, v) is conceptually akin to obj[k] = v.  I've always
liked that about the HTMLElement.appendChild() function.

They're all easy enough to monkey-patch, so this seems a little
bikesheddy to me.


More information about the es-discuss mailing list