Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a benefit in using Lodash in an AngularJS project? [closed]

Has anyone implemented Underscore or Lodash into their existing AngularJS project for a performance boost? If so:

  • Were the changes something noticeable or something that you would recommend?
  • Which functionality from Lodash did you find the most benefits?

I have not actually played with Lodash before and was looking into learning it. But I typically like to learn something and then actually use it shortly after, so that the concepts stick better. If I'll get some good benefits out of implementing Lodash, then I think it would be a good time to learn it now.

I do typically need to perform functions such as filtering or finding an object inside some sort of collection, so I'm thinking that's where I would utilize it the most.

like image 209
kenshin9 Avatar asked Apr 17 '16 01:04

kenshin9


People also ask

What is the negative impact of Lodash?

But the downside of using lodash in an application is that it increases the size of the application which in turn affects the performance of such applications.

Do you still need Lodash?

But Sometimes You Do Need Lodash Not every Lodash utility is available in Vanilla JavaScript. You can't deep clone an object, for example. That's why these libraries are far from obsolete. But if you're loading the entire library just to use a couple of methods, that's not the best way to use the library.

Is Lodash faster than native?

And thus, you start using the methods that are equally easily available inside the JS itself. And this brings us to the next thing, which is performance. Lodash is extremely well-optimized as far as modern JS goes, but, as you may know, nothing can be faster than native implementation.


1 Answers

Well they have really different purposes.

Angular is to build an application. It helps you to structure your code and separate responsibilities between your components (modules, controllers, services, directives, routers).

Lodash is nice to manipulate collections, arrays, objects, strings, etc. It helps your code to be shorter, cleaner and probably faster. It is really well tested and documented. In my opinion, it makes your job simpler.

I use Lodash for 4 years now. I found it useful in all my projects (Backbone, Angular, JavaScript, node, in the unit tests, in the build configuration files (Grunt, Gulp, Webpack)).

PS: Lodash is also a must-have to go into functional programming in JavaScript.

Edit: Example of searching that you can't easily achieve without Lodash

like image 145
GG. Avatar answered Oct 24 '22 00:10

GG.