Immediately Invoked Function Expressions (IIFEs): Encapsulating JavaScript Code
Learn about Immediately Invoked Function Expressions (IIFEs) in JavaScript. Discover how IIFEs create private scopes, prevent global namespace pollution, and improve code organization.
Array Methods Reference
The following table lists all the Array methods available in JavaScript:
Method | Description |
---|---|
concat() |
Returns a new array by combining values of an array specified as a parameter with existing array values. |
every() |
Returns true or false if every element in the array satisfies a condition specified in the callback function. Returns false if even a single element does not satisfy the condition. |
filter() |
Returns a new array with all the elements that satisfy a condition specified in the callback function. |
forEach() |
Executes a callback function for each element of an array. |
indexOf() |
Returns the index of the first occurrence of the specified element in the array, or -1 if it is not found. |
join() |
Returns a string of all the elements separated by the specified separator. |
lastIndexOf() |
Returns the index of the last occurrence of the specified element in the array, or -1 if it is not found. |
map() |
Creates a new array with the results of calling a provided function on every element in this array. |
pop() |
Removes the last element from an array and returns that element. |
push() |
Adds one or more elements at the end of an array and returns the new length of the array. |
reduce() |
Passes two elements simultaneously in the callback function (till it reaches the last element) and returns a single value. |
reduceRight() |
Passes two elements simultaneously in the callback function from right-to-left (till it reaches the last element) and returns a single value. |
reverse() |
Reverses the elements of an array. The element at the last index will be first, and the element at index 0 will be last. |
shift() |
Removes the first element from an array and returns that element. |
slice() |
Returns a new array with specified start to end elements. |
some() |
Returns true if at least one element in the array satisfies the condition in the callback function. |
sort() |
Sorts the elements of an array. |
splice() |
Adds and/or removes elements from an array. |
toString() |
Returns a string representing the array and its elements. |
unshift() |
Adds one or more elements to the front of an array and returns the new length of the array. |