JS Methods Flashcards
1
Q
filter
A
The filter function, rather than deleting elements from the existing army, builds up a new array with only the elements that pas the test. This function is pure. It does not modify the array it is given. (standard method on arrays).
Internal workings:
function filter(array, test) { var passed = []; for (var i = 0; i [{name: "Carolus Haverbeke", ...}]
2
Q
map
A
similar to filter (page 95 in E.JS)
internal workings:
function map(array, transform) { var mapped = []; for (var i= 0; i
3
Q
reduce
A
similar to filter (page 96 in E.JS)
function reduce (array, combine, start) { var current = start; for (var i = 0; i
4
Q
forEach
A
function forEach(array, action) { for (var i = 0; i
5
Q
.isEqual(expected value)
A
Resolves to true