Arrays Flashcards
Get a job
What is … ?
Spread syntax. Allows an iterable, such as an array or string, to be expanded in places where zero or more aguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the properties of an object and adds the key-value pairs to the object being created.
What is .at()?
A method of an Array instance (Array.prototype.at()). Takes an integer value and returns the item at that index, allowing for positive and negative integers. Negative integers count back from the last item in the array.
What is .every()?
An instance method from an Array. Tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
What is .filter()?
Instance method. Creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function.
For primitive values, filter creates a new independent copy.
For objects or arrays, filter creates a new array, but with references to the same objects as the original array.
What is .find()?
Instance method that returns the first element in the provided array that satisfies the provided testing function.
What is .forEach()?
Instance method that executes a provided function once for each array element.
What is .includes()?
Instance method that determines whether an array includes a certain value among its entries. Returns a Boolean value.
What is .join()
Instance method that returns a new string by concatenating all of the elements in this array, separated by commas or a specified separator string. If the array has only one item, then that item will be returned without using the separator.
What is .length
Data property of an array instance. Returns a non negative integer that represents the number of elements in that array. The value is an unsigned 32-bit integer that is always numerically greater that the highest index in the array.
What is .map()
Instance method that creates a new array populated with the results of calling a provided function on every element in the calling array.
What is .push()
Instance method that adds the specified elements to the end of an array and returns the new length of the array.
What is .reduce()?
Instance method that executes a user-supplied “reducer” callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.
What is .some()?
Instance method that tests whether at least one element in the array passes the test implemented byu the provided function. Returns a Boolean value.
What is .splice()
Instance method that CHANGES the contents of an array by removing or replacing existing elements and/or adding new elements in place.
To create a new array with a segment removed and/or replaced without mutating the original array, use toSpliced(). To access part of an array without modifying it, .slice()
What is .slice()?
Instance method that returns a shallow copy of a portion of an array into the new array object selected fromt start to end (end NOT included) where start and end represent the index of items in that array. The original array doesn’t get modified.