Monday, December 14, 2015
JavaScript Concurrency
Friday, July 24, 2015
Efficient counting with lodash
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 length or size() isn't always the most efficient answer.
Friday, June 26, 2015
JavaScript at Scale
My latest book, JavaScript at Scale is available for pre-order now at Packt Publishing, and at Amazon. It'll be fully published in July 2015.
The JavaScript ecosystem is filled to the brim, to the point of overflowing actually, with libraries and frameworks. In this mix, there's some truly remarkable technology. In fact, it's hard to make decisions, given all the overlapping functionality and capabilities. What I've found over the past couple of years is that the architectural considerations get lost in all this choice. That is to say, that we may not be selecting the tool that's best for the front-end architecture we've set out to build. The choice of front-end technology is chosen more so on the generic capabilities of the framework. While TODO applications are a great springboard, to familiarize ourselves with the nature of the technology, that can only take us so far.
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.
Friday, March 6, 2015
Planting values in lodash wrappers
Wrapping values in lodash let's us compose chains of functionality. There's two reasons to do this. The first is that the resulting code is a lot more compact and readable, especially if each chained call is on it's own line. The second reason, now that lazy evaluation is supported in lodash, is efficiency. Some chains won't iterate over the entire collection if it doesn't have to. Now there's a third reason — the plant() function. This function was made available after Lo-Dash Essentials was published, so I'll talk about it here.