Book Image

Learning Underscore.js

By : Alexandru Vasile Pop
Book Image

Learning Underscore.js

By: Alexandru Vasile Pop

Overview of this book

Table of Contents (14 chapters)
Learning Underscore.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Key Underscore functions revisited – each, map, and reduce


The previous chapter introduced key Underscore functions that are representative of the library and mentioned that some functions can be used with either an array or an object. This flexible approach means that some Underscore functions can operate over collections: an Underscore-specific term for arrays, array-like objects, and objects (where the collection represents the object properties). We will refer to the elements within these collections as collection items.

By providing functions that operate over object properties Underscore expands JavaScript reflection like capabilities. Reflection is a programming feature for examining the structure of a computer program, especially during program execution.

JavaScript is a dynamic language without static type system support (as of ES6). This makes it convenient to use a technique called duck typing when working with objects that share similar behaviors. Duck typing is a programming technique...