To use the _.filter methods the first argument that you give it is a collection, such as an array of numbers. The second argument you give is an iteratee method, that can be your own method, or one of the lodash iteratee methods such as _.matches. Also some of those methods are built in, more on that later.
So for a basic example one might have a simple little demo in which I have an array of numbers that are negative and positive, and I use _.filter to create a new array that is only the positive numbers in that array.
Something like this:
The vanilla js Array.filter method can be used in a similar fashion, without the need for lodash. When it comes to something simple, that can work just fine. Also the browser support for Array.filter is pretty good these days, it’s only real old versions of IE that come to mind that present a concern if there is actually a far amount of visitors that still use those platforms. Also if in a node.js environment there is no need for lodash at all if this just happens to be the only method that you are using.
So _.filter is one of the many collection methods in lodash, meaning they are made with both arrays, and objects in general in mind. So if I want to I can just use an Object with _.filter, and it does not even have to be an array like Object.
When trying to use an array method with a plan old object that was not an instance of Array using call, it will typically only work if it is array like. Or in other words it is an object that has keys that are numbers from zero upwards, and a length property that reflects the count of those keys.