JavaScript Array and it's methods

JavaScript arrays are a powerful data structure that is used to store and manipulate collections of data. They provide a wide range of methods to perform different operations on arrays.

The push() method adds one or more elements to the end of an array, while the pop() method removes the last element from an array. The shift() method removes the first element from an array, while the unshift() method adds one or more elements to the beginning of an array.

The slice() method returns a new array that contains a portion of the original array, while the splice() method adds or removes elements from an array. The indexOf() and lastIndexOf() methods return the index of the first and last occurrence of a specified element in an array, respectively.

Other commonly used methods on arrays in JavaScript include forEach(), map(), filter(), reduce(), and sort().

By mastering these array methods, you can write more efficient and readable code in JavaScript, making it easier to work with collections of data.