I'm trying to see if any of the days are '01-01' ( the beginning of the year )
_.some(a.days, function(day){ console.log(day.date.format('DD-MM')) }, "01-01")
Produces this array of dates in my console :
01-01
02-01
03-01
04-01
05-01
06-01
07-01
So then I run without the console.log like so .. :
_.some(a.days, function(day){ day.date.format('DD-MM') }, "01-01")
And it returns :
false
Strange, eh? What do you think I'm doing incorrectly?
You've misunderstood what the last argument to _.some is. The documentation shows that it is the context, or scope, under which the iterator function runs, but it seems like you're trying to use it as a value for equality testing.
You'll need to explicitly execute the equality test yourself.
_.some(a.days, function(day) {
return day.date.format('DD-MM') === "01-01";
});
You appear to be misunderstanding how to use _.some(). Consult the documentation and you'll see that your function needs to return true or false, and the last argument will be used as this in tat function.
You need to do this instead:
_.some(a.days,function(day){ return day.date.format("DD-MM") == "01-01";});