JS Course 1: Fundamental 5 String/Array Methods Flashcards
What does filter() do?
This method is used to filter through an array only including certain items.
What does map() do?
This method is used to do something to every single item in an array. Some things you could do to every item is reformat them, add or takeaway something from them, etc.
What does sort() do?
This method is used to sort an array by a certain designated order. It can also slyly be used to do something to every item in an array.
What does reduce() do?
This method is used to work with every single item in an array, working with a total amount and each item in the array individually.
What does reduceRight() do?
This method does the same as reduce(), but works from the right of the array to the left.
What does Array.from() do?
This method returns an array from any iterable object, like a string for instance.
What does includes() do?
This method works on array and returns a boolean value on if the array contains a certain value in it.
What does some() do?
This method checks if at least on thing in your array meets what you’re looking for and returns a boolean value.
What does every() do?
This method checks if all things in your array meet what you’re looking for, very similar to some()’s syntax.
What does find() do?
This method is similar to filter() but instead of returning a subset of the array you’re working with, it returns JUST the one you are looking for. Specifically, it finds and returns the very first item that meets the criteria you specify.
What does findIndex() do?
This method is the exact same as find(), but returns the index position of the item that first meets the criteria, which is your parameter.
What does findLastIndex() do?
Same as findIndex() but works from the back of the array. Aka, right to left.
What does the […SPREAD] operator do?
This operator takes an iterable, like a string or object and allows us to quickly copy all or part of an existing array or objects into another array or object.
You can think of it as being the opposite of a rest parameter, though they look exactly the same!
What does push() do?
This method adds items to the end of the array. The parameter is what you wish to add to the end of the array.
What does pop() do?
This method extracts the item at the end of the array.