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", ...}]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

forEach

A
function forEach(array, action) {
     for (var i = 0; i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

.isEqual(expected value)

A

Resolves to true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly