JS Arrays Flashcards
What are arrays used for?
To store a list of data/values
Describe array literal notation.
Array literal notation is square brackets [ ]. Within the square brackets, values are nested inside. Each are separated by a comma.
How are arrays different from “plain” objects?
There is an actual order to it the values of the array. Arrays have indexes.
What number represents the first index of an array?
0 (zero)
What is the length property of an array?
The number of indexes in the array — (how many entries are in the array).
How do you calculate the last index of an array?
array[lastIndex] = array.length - 1
What isArray.prototype.filteruseful for?
To filter out arrays
Creates a new array with all elements that pass the test implemented by the provided function.
What isArray.prototype.mapuseful for?
Every element of array
Creates a new array populated with the results of calling a provided function on every element in the calling array.
What isArray.prototype.reduceuseful for?
To reduce an array into a singular value
Executes a reducer function (that you provide) on each element of the array, resulting in a single output value.