Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  125] [ 6]  / answers: 1 / hits: 9539  / 10 Years ago, thu, february 20, 2014, 12:00:00

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()

More From » lodash

 Answers
2

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()

[#47543] Thursday, February 20, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pranavrorys

Total Points: 466
Total Questions: 87
Total Answers: 115

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
pranavrorys questions
Fri, May 27, 22, 00:00, 2 Years ago
Thu, Oct 28, 21, 00:00, 3 Years ago
Sat, May 30, 20, 00:00, 4 Years ago
Fri, Dec 20, 19, 00:00, 5 Years ago
;