Array.prototype.includesAll

Renki Ivanko fatalis.erratum at gmail.com
Tue Jun 14 19:31:17 UTC 2016


There are no items in [] that aren't included in [2,3]. A separate question
is whether undefined should mean []; I'd say it should throw a TypeError
instead.

On Tue, Jun 14, 2016 at 10:06 PM, Shahar Or <mightyiampresence at gmail.com>
wrote:

> What's the point of using `reduce` instead of `every`?
>>
>
> Of course. Updated to use `.every`.
>
> I disagree with this test
>>
>> ```js
>> expect([2, 3].includesAll()).toBe(false)
>> ```
>>
>
>> The array `[2,3]` includes all items in `[]`. So it should return `true`.
>>
>
>  There are no items in `[]` so that doesn't seem like a true statement to
> me.
> However, one could argue both ways. So I look at `.includes`:
> ```js
> [].includes() // false
> [1]includes() // false
> // and so on...
> ```
> So, at least consistency pulls towards `false`.
>
> > It'd be nicer if it took an array, rather than being variadic. That also
> preserves the ability to add extra arguments in the future.
>
> I see the point. Updated to use a single array argument.
>
> ---
>
> Here it is: http://codepen.io/mightyiam/pen/PzNLKr/?editors=0012
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160614/b40096d0/attachment-0001.html>


More information about the es-discuss mailing list