On Mon, Jan 7, 2013 at 7:47 AM, Bradley Meck <[email protected]> wrote:
> ```javascript
> // we only want to print first 2 items
> [1, 2, 3].forEach(function (item) {
> if (item > 2) {
> return;
> }
> console.log(item);
> });
> ```
More efficient, especially for long lists:
```javascript
[1, 2, 3].some(function(item, index) {
console.log(item);
return index === 1;
});
```
(I know that's not really your question, sorry.)
--
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