Showing posts with label ary. Show all posts
Showing posts with label ary. Show all posts

Tuesday, March 10, 2015

Fixed argument counts with lodash ary()

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.