A Quick Guide To An Array And Array Methods

A Quick Guide To An Array And Array Methods

Table of contents

No heading

No headings in the article.

 WHAT IS AN ARRAY.

ARRAY: Bunch of slots that we can put stuffs in, there is an order. ARRAY is also an ordered collection of values. Array is represented as this ([ ]).

 ARRAY METHODS

1: PUSH AND POP: This allows us to add and remove from the end of an Array. POP: Removes from the very end of an Array PUSH: will add one or more to the very end of an Array.

2: SHIFT AND UNSHIFT: This operate at the beginning of the Array SHIFT: Removes any elements from the beginning of an Array. UNSHIFT: How we add a new element to the beginning of an Array.

3: CON CAT: This is used for the combination of an Array.

4: INCLUDES: It returns true of false. It tells us if an Array includes a particular value.

5: INDEX OF: It tells if an element is in an Array or not.

6: REVERSE: This reverse an Array.

7: SPLICE: It's going to change the content of an Array by removing or replacing existing elements or adding a new element in a place.

8: SLICE: This is a way of getting a copy of a portion in an Array.

SORT: The sort() method allows you to sort elements of an array in place. Besides returning the sorted array, the sort() method changes the positions of the elements in the original array. By default, the sort() method sorts the array elements in ascending order with the smallest value first and largest value last.