getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.64k stars 1.96k forks source link

Chapter 4 Abstraction example code error #30

Closed McNathan321 closed 8 years ago

McNathan321 commented 8 years ago

comments[comments.length - 1] = txt;

The text says that this code "sticks the value at the end of the array", but note that this overwrites the last item already in the array (or if the array is empty it creates a property with a key of "-1").

This isn't relevant to the abstraction concept being discussed, but still it feels like an odd thing to do, so it's distracting.

getify commented 8 years ago

Good catch, thanks! :)