Monday, December 14, 2015
Friday, July 24, 2015
Counting with lodash is easy. A lot of the time, an array is returned, so I just need to read the
length property. If I'm working with a chain, I can simply use the
size() function. What I like about
size() is that it works with anything — strings, arrays, and objects. However, using
size() isn't always the most efficient answer.
Friday, June 26, 2015
Tuesday, March 10, 2015
When using functions as callbacks to lodash collection functions, we have to be careful to get the arguments right. This is because functions like map() actually pass more than just the current collection item as the first argument, which is all we need in the majority of cases. It also passes the current index, and the collection itself. Using callback functions that only make use of the first argument is easy. They just work. But if you want to use a function that takes more than just the current item as arguments, then weird things can happen.