Learn about JavaScript arrays and how to work with them.
|
Array.isArray() Checking for Arrays |
The Array.isArray() function checks whether a given value is an array. It returns true if the input is an array; otherwise, it returns false. |
|---|---|
|
forEach() A function to loop through array elements |
The JavaScript's forEach() function is a widely used and convenient method to loop through array elements and run a callback for each one. Explore the concepts and examples to master array processing. |
|
map() Ideal for mapping array data to new values |
The JavaScript Array map() function creates a new array by applying a callback to each element. Learn the concept and explore practical examples to use it effectively. |
|
filter() Filter Elements with a Callback |
The filter() function for arrays filters an array, keeping only the values that meet a specified condition. By providing a callback function, it returns a new array containing only the elements that satisfy the condition. |
|
find() Finding a First Element with a Callback |
The find() function for arrays returns the first element that satisfies the condition defined by a callback function. If no element matches the condition, it returns undefined. |
|
findIndex() Finding an Element's Index with a Callback |
The findIndex() function for arrays returns the index of the first element that satisfies the condition defined by a callback function. If no element matches the condition, it returns -1. |
|
includes() Checking for an Element |
The includes() function for arrays checks whether a given array contains a specified element and returns true if it does, or false otherwise. |
|
indexOf() Find the First Index of an Element |
The indexOf() function for arrays returns the index of the first found (occurrence of the) specified element. If the element is not found, it returns -1. |
|
slice() Extract Array Elements by Index Range |
The slice() function for arrays extracts a portion of an array using an index range and returns a new array without modifying the original. |
|
join() Joining Array Elements into a String |
The join() function for arrays joins each element of a given array using a specified separator and returns a single string. |
|
reduce() Reducing an Array to a Single Value |
The reduce() function for arrays iterates through an array using a callback function to repeatedly reduce it to a single value. The original array remains unchanged. |
|
reverse() Reversing Original Array Elements |
The reverse() function for arrays reverses the order of the elements, turning the first element into the last and the last element into the first. |
|
sort() Sorting Original Array Elements |
The sort() function for arrays returns the original array after sorting its elements; by default, it sorts according to the Unicode code point order of strings, and a custom sorting criteria can be specified through a callback function. |
|
concat() Concatenating Arrays or Arrays and Values |
The concat() function for arrays concatenates one or more arrays or values in order to create a new array. Each element or value is appended to the end of the previous array, and the function returns the concatenated array without modifying the original. |
|
shift() Remove the First Element from an Array |
The shift() function removes the first element from an array and returns it. This operation decreases the array's length by one. |
|
pop() Remove the Last Element from an Array |
The pop() function removes the last element from an array and returns it. This operation decreases the array length by one. |
|
unshift() Add Elements to the Start of an Array |
The unshift() function prepends one or more elements to the beginning of an array—similar to inserting items at the front. This also increases the array's length. |
|
push() Add Elements to the End of an Array |
The push() function adds one or more elements to the end of an array—essentially 'pushing' them onto it, like stacking items. This also increases the array's length. |