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?
Underscore provides over 100 functions that support both your favorite workaday functional helpers: map, filter, invoke — as well as more specialized goodies: function binding, javascript templating, creating quick indexes, deep equality testing, and so on.
An underscore as the first character in an ID is often used to indicate an internal implementation that is not considered part of the API and should not be called by code outside that implementation.
The _. template() function is an inbuilt function in the Underscore. js library of JavaScript which is used to compile JavaScript templates into functions that can be evaluated for rendering. Useful for rendering complicated bits of HTML from JSON data sources.
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"; });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With