This works, but how can I chain it?...
allWeeks = _.flatten(_.pluck(dates.months, 'weeks'))
allDays = _.flatten(_.pluck(allWeeks, 'days'))
I've tried:
allDays = _.chain(dates.months).pluck('weeks').flatten().pluck('days').flatten()
And this:
allDays = _(dates.months).pluck('weeks').flatten().pluck('days').flatten()
Instead of deleting this question out of sheer embarrassment, I will leave the answer here for any other poor schmuck out there wondering "why the heck isn't my lodash chain working?!":
You must end the chain with
.value()
so this:
allDays = _.chain(dates.months).pluck('weeks').flatten().pluck('days').flatten().value()
and this:
allDays = _(dates.months).pluck('weeks').flatten().pluck('days').flatten().value()
You have to know that starting for Lodash 4.0.0, _.pluck() is replaced by _.map() so for example:
var objects = [{ 'a': 1 }, { 'a': 2 }];
// in 3.10.1
_.pluck(objects, 'a'); // → [1, 2]
_.map(objects, 'a'); // → [1, 2]
// in 4.0.0
_.map(objects, 'a'); // → [1, 2]
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