Functional JavaScript

Errata for Functional JavaScript

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
PDF Page 14, 15
example code at the bottom of 14, graph at 15

the function comparator is flaw and must not be used with array.sort to the function sort: -1 means LT, 1 means GT and 0 means EQ. To the comparator function: -1 means the first test to pass, 1 means the opposite of first test, and 0 means both tests failure. Comparator drifts away from what really matters ordinal position. if the first test has predicate lessThan and x is less than y, ok but if the first test has the pedicate greaterThan and x is greater than y, comparator returns -1 meaning GT, and sorts only accepts -1 to mean LT. Besides comparator only accepts 2 parameters predicates, isPrime, isOdd, isEven are one parameter predicates. Don't say they can be passed to comparator, they do not fit comparator contract.

Alfgaar  Jul 22, 2015 
Printed Page 15
United States

The comparator function on page 14 won't work as intended if the predicate function passed to it returns the true for both less than and equal to. In that case the comparator function will never return zero. The predicate function passed to comparator on page 15 should be "less", not "lessOrEqual". The easiest fix would be to change "lessOrEqual" to "less" throughout the examples in this section and of course use < instead of <=.

Mark Volkmann  Oct 05, 2014 
Other Digital Version 15

In Figure 1-10, the left side shows predicates named isPrime, isOdd and isEven. These predicates act on a single value and do not compare one value to another, so it doesn't make sense to use them with the comparator function.

Ken Carpenter  Apr 05, 2015 
PDF Page 18
United States

At the top of the page in the functions below the "second" should be _.second and the "nth(row, 2)" should be "_.nth(row, 2)" Both of these are underscore functions that are not written as such and are therefore very confusing. function selectAges(table) { return, second)); } function selectHairColor(table) { return, function(row) { return nth(row, 2); })); }

Andrew Nguyen  Mar 30, 2015 
Printed Page 20
United States

It is implied that these lines are equivalent, but they are not. return _.isFunction(doSomething) ? doSomething() : doSomething; return action(); The first line only calls doSomething if it is a function. The second line assumes action is a function.

Mark Volkmann  Oct 05, 2014 
Printed Page 21
Last Code Block

// 'array[i]' should be 'elem' or, // 'i' should be the second parameter to anonymous function. _.each(array, function(elem) { doSomething(array[i]); }

Robert Chrzanowski  Feb 28, 2015 
Printed Page 36
United States

It seems undesirable for the functions allOf and anyOf to evaluate their arguments from right to left. I think most programmers would expect the opposite and assume that for purposes of short-circuiting their evaluation.

Mark Volkmann  Oct 05, 2014 
Printed Page 37
United States

In footnote 6 about apply it says "I use null to signal that this should just refer to the global object". That's not correct. Passing null signals that this should refer to null. If inside the function a call is made to, it won't try to call foo as a method on the global object. There will be an error.

Mark Volkmann  Oct 05, 2014 
Printed Page 39
United States

I think the cat function should verify that head is an array so it knows it can call concat on it. if (existy(head) && _.isArray(head))

Mark Volkmann  Oct 05, 2014 
Printed Page 46
United States

The function rename seems overly complicated. Maybe it is just written that way to illustrate use of reduce, omit, and construct. Wouldn't it be easy to understand written like this? function myRename(obj, newNames) { var result = {}; Object.keys(obj).forEach(function (oldName) { var newName = newNames[oldName]; var name = newName === undefined ? oldName : newName; result[name] = obj[oldName]; }); return result; }

Mark Volkmann  Oct 05, 2014 
Other Digital Version 76
code listing

I have the Amazon Kindle version of this book and it is fabulous. I just wantedto point out that the invoker function listed on page 76 could be improved by not having to take two arguments. The first argument which is the name of the function can simply be retrieved using the 'name' property of the function itself. I have the changed invoker function here:

Bijoy Thomas  Jul 03, 2015 
PDF Page 80

In the following line, there should be a semi-colon following the return statement: _.reduce(nums, function(total, n) { return total * n });

David Rogers  Oct 10, 2014 
PDF Page 98
In the middle of the page

In the first example using the curry3 function, it reads: var songsPlayed = curry3(_.uniq)(false)(songToString); It should be: var songsPlayed = curry3(_.uniq)(songToString)(false); Both versions work because _.uniq would shift the parameters when the second parameter is not boolean, but the idea of the text was about letting curry3 take the last (third) parameter in the first function call, which should be 'songToString'.

Dapeng Li  Nov 30, 2015 
PDF Page 101,103
source example and following paragraph on 101, first source examples on 102 and 104

In all four locations, functions that are intended to be implementations of 'divide10By' using partial application, are named 'over10Part' and 'over10Part1'. These names imply that the functions will do the inverse of what they do, and they would be more correctly named 'divide10ByPart' and 'divide10ByPart1'.

Rod Knowlton  Jan 05, 2015 
PDF Page 214
1st Paragraph

I believe "proccess" is spelled incorrectly. If I'm correct-- we just need one less c: "process." Surrounding context: "... simple data is best because you can use common tools and functions to proccess it ..."

Jed Northridge  Jan 02, 2015