Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show complex use-cases #12

Closed
stevemao opened this issue Jan 26, 2016 · 4 comments
Closed

Show complex use-cases #12

stevemao opened this issue Jan 26, 2016 · 4 comments
Labels

Comments

@stevemao
Copy link
Member

  _.each([1, 2, 3], function(value, index) {
    console.log(value);
  });

is simple use-case only
what about

  _.each([1, 2, 3], function(value, index) {
    ...
    return false;
  });
@cht8687
Copy link
Member

cht8687 commented Jan 26, 2016

I think keep it simple and clean is important. But complex use-cases are also fine I think.

@stevemao
Copy link
Member Author

The reason is Array.prototype.forEach does not support return false to end loop as _.each do.
Also _.each is faster as it's a stripped down version of Array.prototype.forEach. So the equivalent should be a for loop with break.

@bholben
Copy link

bholben commented Jan 27, 2016

I really like the list. I'm putting together a similar blog series about how/where to use Lodash. My background is with some larger, computationally intensive applications, so my perspective may be a little different. Reading this makes me want to add some details about when the Lodash investment is worth it and when it is not. Here's my summary of some advantages of the Lodash looping constructs vs. the built-ins... http://www.bholben.com/blog/lodash-is-superior-to-array-prototype-loops/

@cht8687
Copy link
Member

cht8687 commented Jan 27, 2016

Hi @bholben that's a really nice article for comparing the difference between the two! Many thanks to share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants