On Mon, Feb 13, 2012 at 11:21 AM, Axel Kittenberger <[email protected]> wrote:
> some() is only for Arrays tough.

Same with forEach.  I had forgotten about Array.prototype.some().

If you want the short-circuit of some, use my code from above, but
call it "some" to avoid confusion.

> On Mon, Feb 13, 2012 at 5:47 PM, substack <[email protected]> wrote:
>> On Feb 13, 7:01 am, Axel Kittenberger <[email protected]> wrote:
>>> Why they didn't make the standard forEach in that returning false
>>> terminates the loop is beyond me...
>>
>> You can just abuse the short-circuiting of [].some:
>>
>>> [ 1, 2, 3, 4, 5, 6, 7 ].some(function (x) { console.log(x); if (x > 4) 
>>> return true })
>> 1
>> 2
>> 3
>> 4
>> 5
>>
>> Instead of `return false`, it's `return true`.
>>
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to