Skip to Content
Mastering JavaScript Functional Programming - Second Edition
book

Mastering JavaScript Functional Programming - Second Edition

by Federico Kereki
January 2020
Intermediate to advanced
470 pages
11h 13m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming - Second Edition

Chapter 5, Programming Declaratively – a Better Style

5.1. Filtering... but what? Boolean(x) is the same as !!x, and it turns an expression from being truthy or falsy into true or false, respectively. Thus, the .filter() operation removes all falsy elements from the array.

5.2. Generating HTML code, with restrictions: In real life, you wouldn't limit yourself to using only filter(), map(), and reduce(), but the objective of this question was to make you think about how to manage with only those. Using join() or other extra string functions would make the problem easier. For instance, finding out a way to add the enclosing <div><ul> ... </ul></div> tags is tricky, so we had to make the first reduce() operation produce an array so that we could ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming

Mastering JavaScript Functional Programming

Federico Kereki

Publisher Resources

ISBN: 9781839213069Supplemental Content