You are not wrong! Lodash has a bunch of methods that just make doing certain tasks easier. Adding Lodash to your Javascript project adds these methods some other frameworks like Django or Ruby on Rails would have out of the box. Such as the zip method in Ruby on Rails which will zip together two arrays into one. Javascript doesn't have this functionality out of the box... Lodash has a _.zip method. Don't get me wrong you could also do this with the array .map method in Javascript. As for the library overhead you could always import each method individually.
Frontend developer by day, iOS developer by night. Currently working on learning iOS development and my own blog, Mike Decodes, where I'm decoding the tech industry. Come hang out with me on Twitter!
You certainly should only import the modules you use, otherwise a few convenience methods are taking up more space than whole frameworks like React. Functions such as debounce() in lodash have tons of options that make them much heavier than lightweight implementations (which are mostly what it is used for) - if you aren't using the options for trailing and leading edges, it's costing "something".
For me in big apps that are likely to use lots of utility methods over time, I'd take Sugar.js because that has some really useful functions - like Date.create("Next monday at 2pm"), debounce etc. It's also 1/3 the size of lodash if you include it all (and you don't have to).
It's a little different concat would join the two arrays. So if you had [1, 3, 5] and [2, 4]. The results of concatenation would be [1, 3, 5, 2, 4]. The zip method would zip the two arrays together like a zipper. The results would look like this [1, 2, 3, 4, 5]
You are not wrong! Lodash has a bunch of methods that just make doing certain tasks easier. Adding Lodash to your Javascript project adds these methods some other frameworks like Django or Ruby on Rails would have out of the box. Such as the zip method in Ruby on Rails which will zip together two arrays into one. Javascript doesn't have this functionality out of the box... Lodash has a _.zip method. Don't get me wrong you could also do this with the array .map method in Javascript. As for the library overhead you could always import each method individually.
Ex. const zip = require("lodash/zip");
Probably would have been better to show examples of where using Lodash would actually have some benefit
Maybe in my next post! 😉 say tuned lol!
'Tuned'
I see what you did there 👀
You certainly should only import the modules you use, otherwise a few convenience methods are taking up more space than whole frameworks like React. Functions such as
debounce()in lodash have tons of options that make them much heavier than lightweight implementations (which are mostly what it is used for) - if you aren't using the options for trailing and leading edges, it's costing "something".For me in big apps that are likely to use lots of utility methods over time, I'd take Sugar.js because that has some really useful functions - like Date.create("Next monday at 2pm"), debounce etc. It's also 1/3 the size of lodash if you include it all (and you don't have to).
I don't know anything about ruby on rails but isn't that concat? w3schools.com/jsref/jsref_concat_a...
It's a little different concat would join the two arrays. So if you had [1, 3, 5] and [2, 4]. The results of concatenation would be [1, 3, 5, 2, 4]. The zip method would zip the two arrays together like a zipper. The results would look like this [1, 2, 3, 4, 5]
So basically concat + sort?