(Map|Set|WeakMap)#set() returns `this` ?

Tab Atkins Jr. jackalmage at gmail.com
Wed Dec 5 11:57:16 PST 2012

On Wed, Dec 5, 2012 at 10:04 AM, Mark S. Miller <erights at google.com> wrote:
> On Wed, Dec 5, 2012 at 1:50 AM, Jussi Kalliokoski
> <jussi.kalliokoski at gmail.com> wrote:
>> My 2 cents against the windmills...
>> I personally think returning `this` in absence of any meaningful value (and
>> chaining in general) is a bad pattern. Chaining leads to worse readability
>> (there's nothing subjective about this, if you have to scan the code to
>> another page to figure out which object the code is interacting with, it's
>> bad readability)
> This is an excellent point, and has changed my mind. I return to not
> supporting the "return this" for these cases. Thanks.

The readability of chaining *is* very subjective.  I find it perfectly readable.

Andrea and a few others feel strongly about this, and I respect that.
But most JS libraries have gone the other way, and authors in general
seem to like that direction.  This constitutes pretty clear evidence
about which pattern JS devs en masse prefer, and we shouldn't pretend
like we know better than them.  In the absence of technical problems
that doom a solution, let's vote with the herd.


More information about the es-discuss mailing list