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

Rick Waldron waldron.rick at gmail.com
Wed Dec 5 12:43:11 PST 2012


On Wed, Dec 5, 2012 at 3:26 PM, Domenic Denicola <
domenic at domenicdenicola.com> wrote:

> Readability or library preference aside, I still think it's bizarre that
>
> map.set(key, val)
>
> is analogous to
>
> (dict[key] = val, dict)
>
> and not to
>
> dict[key] = val
>
> When I'm using a fluent library like jQuery or a configuration DSL like
> those in the npm packages surveyed, I can see the attraction of chaining.
> But when I am using a basic primitive of the language, I expect uniformity
> across primitives.
>

This argument won't hold when the language doesn't make any such
"uniformity" promises, eg.

array.push(val); // new length
array[ array.length - 1 ] = val; // val


Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121205/1bc9dc0b/attachment.html>


More information about the es-discuss mailing list