JavaScript Array/String Methods

Filter()

Input: callbackFn, thisArg (Optional)
Output: Array
Callback-input: element, index, array
Callback-output: boolean

The filter() method returns a new array with all elements that pass the test defined by the given function.

Filter()

Map()

Input: callbackFn, thisArg (Optional)
Output: Array
Callback-input: element, index, array
Callback-output: elements

The map() method creates a new array with the results of calling a function for every array element.

Map()

Reduce()

Input: callbackFn, initialValue (Optional), thisArg (Optional)
Output: anything
Callback-input: accumulator, currentValue, currentIndex, array
Callback-output: new accumulator (any)

The reduce() method executes a reducer function on each element of the array and returns a single output value.

Reduce()

forEach()

Input: callbackFn, thisArg (Optional)
Output: None (undefined).
Callback-input: element, index, array
Callback-output: elements

The forEach() method executes a provided function for each array element.

forEach()

Pop()

Input: none
Output: element | undefined
Callback-input: -
Callback-output: -

The pop() method removes the last element from an array and returns that element.

Pop()

Push()

Input: element1, …, elementN
Output: Returns the new (after appending the arguments) length of the array upon which the method was called.
Callback-input: -
Callback-output: -

The push() method adds zero or more elements to the end of the array.

Push()

Shift()

Input: none
Output: element | undefined
Callback-input: -
Callback-output: -

The shift() method removes the first element from an array and returns that element.

Shift()

Unshift()

Input: element1, …, elementN
Output: Returns the new (after adding arguments to the beginning of array) length of the array upon which the method was called.
Callback-input: -
Callback-output: -

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

Unshift()

Concat()

Input: value1, …, valueN (Optional)
Output: Returns a newly created array after merging all arrays/values passed in the argument.
Callback-input: -
Callback-output: -

The concat() method returns a new array by merging two or more values/arrays.

Concat()

Sort()

Input: compareFn (Optional)
Output: The reference to the original array, now sorted. Note that the array is sorted in place, and no copy is made.
Callback-input: a, b
Callback-output: sort order

The sort() method sorts the items of an array in a specific order (ascending or descending).

Sort()

Splice()

Input: start, deleteCount (Optional), item1,…, itemN (Optional)
Output: Returns an array containing the deleted elements
Callback-input: -
Callback-output: -

The splice() method modifies an array (adds, removes or replaces elements).

Splice()

Slice()

Input: start (Optional), end (Optional)
Output: new Array
Callback-input: -
Callback-output: -

The slice() method returns a shallow copy of a portion of an array into a new array object.

Slice()

Split()

Input: separator (Optional), limit (Optional)
Output: Returns an Array of strings, split at each point where the separator occurs in the given string.
Callback-input: -
Callback-output: -

The split() method divides a string into substrings and returns them as an array without modifying the original string.

Split()

Reverse()

Input: None.
Output: Returns the array after reversing the order of its elements.
Callback-input: -
Callback-output: -

The reverse() method returns the array in reverse order. The method changes the original array.

Reverse()

Join()

Input: separator (Optional). If omitted, the array elements are separated with a comma (",").
Output: Returns a String with all the array elements joined by separator.
Callback-input: -
Callback-output: -

join() combines all array elements into a single string with a specified separator, without changing the original array.

Join()

Includes()

Input: searchElement, fromIndex (Optional)
Output: true/false
Callback-input: -
Callback-output: -

The includes() method checks if an array contains a specified element or not.

Includes()

IndexOf()

Input: searchElement, fromIndex (Optional)
Output: The first index of searchElement in the array; -1 if not found.
Callback-input: -
Callback-output: -

indexOf() compares searchElement to elements of the Array using strict equality (similar to triple-equals operator or ===).

IndexOf()

Find()

Input: callbackFn, thisArg (Optional)
Output: Returns the first element in the array that satisfies a given function, or undefined if none do.
Callback-input: element, index, array
Callback-output: true/false

The find() method returns the value of the first array element that satisfies the provided test function.

Find()

Every()

Input: callbackFn, thisArg (Optional)
Output: true/false
Callback-input: element, index, array
Callback-output: true/false

The every() method checks if all array elements pass a given test function without modifying the original array.

Every()

Some()

Input: callbackFn, thisArg (Optional)
Output: true/false
Callback-input: element, index, array
Callback-output: true/false

The some() method tests whether any of the array elements pass the given test function. Change the original array

Some()

Fill()

Input: value, start (Optional), end (Optional)
Output: Returns the modified array, filled with value from start to end.
Callback-input: -
Callback-output: -

The fill() method returns an array by filling all elements with a specified value. fill() is a mutator method.

Fill()