Aw, it's missing the functional Array functions like map, filter, reduce, etc...
They are important because they can be applied to element results, strings, objects with a .length, Regex results, or anything that looks like a collecttion of some sort for some incredibly terse and functional code.
For example, if you want to generate JSON from a querySelectorAll, you can just map over the results and return object literals in the anonymous function...
12
u/Archenoth with(RegExp) eval($_); Mar 17 '15 edited Mar 17 '15
Aw, it's missing the functional Array functions like
map,filter,reduce, etc...They are important because they can be applied to element results, strings, objects with a
.length, Regex results, or anything that looks like a collecttion of some sort for some incredibly terse and functional code.For example, if you want to generate JSON from a
querySelectorAll, you can justmapover the results and return object literals in the anonymous function...So, the following would return server-ready JSON:
I'd argue that the Array prototype functions are some of the most important in JavaScript.