It depends on what you really want to do.
You want to know how to implement the lodash functions that you use with the modern browser API
Use the suggested solutions in this section.
Do you want to remove lodash dependency
If so, I think you want to publish the library without dependencies.
Please note that Underscore and Lodash are under the MIT license , so you can simply copy / paste the functions you need and directly paste them into your distributed / lib / whatever application.
Do you want good performances
Just keep in mind that using a modern browser API is not always a way to achieve better results. Javascript is now very fast (if you are not directly manipulating the DOM, check out ReactJS ), and it is often faster to use efficient JS code than poorly designed native code. Also, not all browser API functions are implemented using native code.
By combining underscore expressions, at each step you create an intermediate array, which leads to increased memory consumption and garbage collection activity. According to the size of your initial array, this may affect the performance of your application, and it would be better to use imperative code.
The modern technique of processing these intermediate distributions of arrays while maintaining the style of functional programming is to use converters . There are currently two main implementations of JS:
This can be considered as premature optimization for small arrays, but in fact, converters are not very complex and do not represent such complexity. If you want to feel at home, you can use underscore-tranceducers , which offers an API very similar to Underscore.