Arrays Operations Commonly Used in React
Update your knowledge about useful array methods for React development.
Array operations
Array methods can be categorized as destructive or non-destructive. A destructive method is one that mutates the original array while a non-destructive method is one that doesn’t mutate the array.
let students = [
"james john", "mahmud strobe", "favour listena", "andrew johnson", "jackson cassidy", "brenda wise", "favour suker"
];
We’ll use the students
array above to explain some of the methods and operations of arrays.
The map()
method
This is one of the most commonly used array methods in React. It’s used to perform an operation on each item of the array. It doesn’t mutate the original array. The map
method loops over all items in the array and returns a new array.
Get hands-on with 1400+ tech skills courses.