Creating mixins

The last major building block we'll visit in this chapter is the mixin. Lo-Dash has a mixin() function that lets us extend the API by providing our own functions. There are two reasons you'd want to do such a thing. The first is that by placing your generic toolset in the Lo-Dash object, you can have access to them wherever the _ symbol is accessible. The second reason is that once you've mixed in your own function, it can be used as a piece in a function call chain.

Creating an average() function

There's only so many utilities a library such as Lo-Dash can feasibly ship. The ones that are viewed as most applicable to common users are the ones we get out of the box. This doesn't mean that the application you're working on doesn't ...

Get Lo-Dash Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.