List of all array function in angular

Mohammad Zubair 0

In Angular, you can utilize various array functions to manipulate and work with arrays. Here is a list of commonly used array functions in Angular:

1. forEach(): Executes a provided function once for each array element.
2. map(): Creates a new array with the results of calling a provided function on every element in the array.
3. filter(): Creates a new array with all elements that pass a provided test function.
4. find(): Returns the first element in the array that satisfies a provided testing function.
5. findIndex(): Returns the index of the first element in the array that satisfies a provided testing function.
6. some(): Checks if at least one element in the array satisfies a provided testing function.
7. every(): Checks if all elements in the array satisfy a provided testing function.
8. reduce(): Applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.
9. reduceRight(): Applies a function against an accumulator and each element in the array (from right to left) to reduce it to a single value.
10. sort(): Sorts the elements of an array in place and returns the sorted array.
11. concat(): Returns a new array that concatenates two or more arrays.
12. includes(): Determines whether an array includes a certain element and returns a boolean value.
13. indexOf(): Returns the first index at which a given element can be found in the array, or -1 if it is not present.
14. lastIndexOf(): Returns the last index at which a given element can be found in the array, or -1 if it is not present.
15. slice(): Returns a shallow copy of a portion of an array into a new array.
16. splice(): Changes the contents of an array by removing or replacing existing elements and/or adding new elements.
17. push(): Adds one or more elements to the end of an array and returns the new length of the array.
18. pop(): Removes the last element from an array and returns that element.
19. shift(): Removes the first element from an array and returns that element, shifting all subsequent elements to a lower index.
20. unshift(): Adds one or more elements to the beginning of an array and returns the new length of the array.

These array functions can be applied to arrays in Angular applications to perform various operations such as iteration, transformation, filtering, and more.


Mohammad Zubair

I'm Mohammad Zubair, a passionate software engineer working in the dynamic world of IT. Currently, I'm proud to be a part of HawarIT, a thriving Dutch-Bangladeshi joint venture company, where I contribute my expertise and enthusiasm to the field of software engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *