Continuation of function - Arrow function.
An arrow function is a concise way to define small, single-purpose functions in JavaScript.
Arrow Function Structure;
Const AddNum= ( ) => {
}
Now, Let's look into Arrays and Array Methods.
An Array is a list-like structure that stores multiple values in a single variable. Each item in the array has an index, starting from 0.
Also, an array is a data structure that stores a collection of elements, each identified by an index or key.
Array Methods:
-
Push: Adding elements to the end of the array (e.g.
array.push(element)). -
Pop: Removing the last element from the array (e.g.
array.pop()). -
Shift: Removing the first element from the array (e.g.,
array.shift()). -
map(): Creates a new array with the results of applying a function to each element
-
filter()*: Creates a new array with elements that pass a test.
-
reduce()*: Applies a function to each element, accumulating a value.
-
forEach(): Iterates over the array, executing a function for each element.
Benefits of Arrays
-
Efficient data storage: Arrays provide a compact way to store collections of data.
-
Fast access: Arrays allow for fast access to elements using their index.
-
Flexible: Arrays can be used in a variety of contexts, from simple data storage to complex data processing.