Diverse Arrays Operation In JavaScript
Arrays are list-like objects which contains a group of elements. Arrays stored data in a very organized manner as a result data can be easily stored or searched.
Let’s play with Array Operation
Method push/unshift
· push adds an element to the end
· unshift add an element to the beginning.
Method pop/shift
· pop remove an element from the end
· shift removes an element from the beginning.
Multiple arrays concatenate using (…three Dots) spread operator
Multiple Array concatenate using spread operator.
map, filter, find on an array of objects
Array element slice and spice
· The splice() method changes an array by adding or removing elements from it them returns the removed item(s) in an array and slice() method copies a given part of an array then returns the selected element in an array, as a new array object.
· The splice() method changes the original array whereases slice() method doesn’t change the original array.
slice operation:
splice operation: