Re: Why using the size property in set
yes in fact it makes sens because Set.length is the property of Set, not necessary the length of the collection. Thanks for your answers :) 2014-07-31 17:12 GMT+02:00 Allen Wirfs-Brock al...@wirfs-brock.com: This was intentional Allen On Jul 31, 2014, at 5:24 AM, Nathan Wall ww...@google.com wrote: Also, whether this was intentional or not, I think it's nice for objects with `length` properties to all have properties at indices from `0` to `length` (so they work in the `Array.prototype` methods) making `'length' in foo` a lazy-man's `isArrayLike`. ```js var forEach = Function.prototype.call.bind(Array.prototype.forEach); forEach('foo', function(u) { console.log(u); }); ``` On Thu, Jul 31, 2014 at 7:21 AM, David Bruant bruan...@gmail.com wrote: Le 31/07/2014 09:25, Maxime Warnier a écrit : Hi everybody, I was reading the doc for the new Set method and something suprised me : Why Set uses the size method instead of the length property ? IIRC and with my own words length refers more to something that can be measured contiguously (like a distance or a number of allocated bytes, etc.) while size doesn't have this contiguous aspect to it. David ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss -- Maxime WARNIER ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Why using the size property in set
Le 31/07/2014 09:25, Maxime Warnier a écrit : Hi everybody, I was reading the doc for the new Set method and something suprised me : Why Set uses the size method instead of the length property ? IIRC and with my own words length refers more to something that can be measured contiguously (like a distance or a number of allocated bytes, etc.) while size doesn't have this contiguous aspect to it. David ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Why using the size property in set
This was intentional Allen On Jul 31, 2014, at 5:24 AM, Nathan Wall ww...@google.com wrote: Also, whether this was intentional or not, I think it's nice for objects with `length` properties to all have properties at indices from `0` to `length` (so they work in the `Array.prototype` methods) making `'length' in foo` a lazy-man's `isArrayLike`. ```js var forEach = Function.prototype.call.bind(Array.prototype.forEach); forEach('foo', function(u) { console.log(u); }); ``` On Thu, Jul 31, 2014 at 7:21 AM, David Bruant bruan...@gmail.com wrote: Le 31/07/2014 09:25, Maxime Warnier a écrit : Hi everybody, I was reading the doc for the new Set method and something suprised me : Why Set uses the size method instead of the length property ? IIRC and with my own words length refers more to something that can be measured contiguously (like a distance or a number of allocated bytes, etc.) while size doesn't have this contiguous aspect to it. David ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss