Reputation: 1569
I have an array
arr = ["jenny", "lucy", "jason"]
I do
_.some(arr, "jenny")
and it throws false
Upvotes: 1
Views: 2267
Reputation: 417
Your call to _.some
needs to have a function callback as its second parameter:
arr = ["jenny", "lucy", "jason"];
_.some(arr, function(val) {return val === 'jenny'});
Upvotes: 2
Reputation: 33726
In your case (an array
) the predicate must be a function to check the values.
var arr = ["jenny", "lucy", "jason"]
var result = _.some(arr, (x) => x === "jenny");
console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
_.some(collection, [predicate=_.identity])
Arguments
collection (Array|Object)
: The collection to iterate over.[predicate=_.identity] (Function)
: The function invoked per iteration.
Upvotes: 5