You have to return
the result of _.has
from the callback.
Lo-Dash _.has nested inside _.every not returning what I expect
-
17-07-2023 - |
Question
I assume I'm missing something obvious, but in this code snippet using Lo-Dash:
var collection = [{"foo": 1, "bar": 2}, {"foo": 3, "bar": 4}];
var result = _.every(collection, function(testObj) {
_.has(testObj, "foo");
});
console.log(result);
I would expect result to be true, but it evaluates to false. Here's a fiddle if you want to play with it: http://jsfiddle.net/XcZnd/
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow